It’s painful to remote to the server every time we want to deploy our website.
- Gitlab Integration Webhook
- node-gitlab-webhook — Gitlab Webhooks handler based on Node.js. Support multiple handlers.
- pm2 — Advanced, production process manager for Node.js
- shelljs — Unix shell commands for Node.js
Get Started — The Quite Hard Part
Create Bash Script for pulling and building our script
Create Node.js Application for Listening for Webhook
Create project directorymkdir node-hook
Change Directory to the projectcd node-hook
Initialize NPMnpm init -y
Install Needed Packagesnpm install shelljs node-gitlab-webhook — save
Create Entry Pointtouch index.js
Installing PM2sudo npm i -g pm2
Run the Applicationpm2 start index.js
Automated Startup (Optional)sudo pm2 startup ubuntu
Configuration Gitlab Project — The Simple Part
Go to YourProject > Setting > Integrations
There are two input fields, URL and Secret Token
Secret Token : superS3cret
You can also Trigger other events like Tag, Comments, Issues and more.
Enable SSL verificationHTTPS
This is not perfect enough but it works