We now have a demand, the project package upload to
gitlab
, orgithub
after, the program can automatically deploy without manually update and run the project to the server, how to do? We can use heregitlab
andgithub
the hooks, the principle is that every time we have to requestgitlab
andgithub
, They will then access the server to pull the hook according to our configuration, thewebhook
hook procedure will always be listening on a port request, a but they sent me the receipt of the request, then you know that the user has submitted a request, then we can usewebhook
to perform deployment script command procedure.
user's guidance
Gitlab way
Download Project
git clone https://github.com/dounine/gitlab-webhook.git
Line 9 to amend its own password file reading position
fs.readFile('/root/issp/gitlab-webhook/password.txt', 'utf8',....
Modify line 65 to execute a shell script location
cmd.get('/root/issp/docker/' + event.mode + '/run.sh',....
run
cd gitlab-webhook && ./start.sh
gitlab
Configuration
URL:http://xxxxx:7777/webhook
Secret Token:password.txt里面的密码
Github way
Download Project
git clone https://github.com/dounine/github-webhook.git
Modify the position of the third row of the password file itself
var secretPassword = 'abc123' //github secret安全密码
Modify Line 7 shell script location
var bash = '/root/xxx/test.sh' //执行的脚本
run
cd github-webhook && ./start.sh
gitlab Configuration
Payload URL:http://xxxxx:7777/webhook
Secret:安全密码