Auto git-pull by GitHub WebHook
깃허브 웹훅을 활용하여, 레포지토리 업데이트 시 Git pull 수행하기
- Environment in this case
Description Value GitHub Repository https://github.com/RyuaNerin/portfolioGitHub WebHook Payload URL https://ryuar.in/__pushGitHub WebHook Secret 1234567890Local Repository Directory /srv/http/ryuar.in/_defaultHTTP Server Binding tcp :8081
-
Config Github Actions
- Repository Page -> Settings -> Webhooks
- Click Add webhook
- Input
https://ryuar.in/__pushin Payload URL - Input
1234567890in Secret - Select Just the push event.
- Click
Add Webhook.
-
Clone target repository.
> git clone https://github.com/RyuaNerin/portfolio -o /srv/http/ryuar.in/_default -
Clone this repository, then build package
> git clone https://github.com/RyuaNerin/ghpull.git > cd ghpull > go build -v
-
Copy binary.
> sudo cp ghpull /usr/local/bin/ghpull -
Edit Nginx Configure.
> sudo vi /etc/nginx/conf.d/ryuar.in.conflocation /__push { proxy_pass http://unix:/run/ghpull/ryuar.in.sock; }
-
Run ghpull and test.
> sudo -u ghpull /usr/local/bin/ghpull -unix "/run/ghpull/ryuar.in.sock" -path "/__push" -dir "/srv/http/ryuar.in/_default" -secret "1234567890"
-
To Use systemd.
> sudo cp ghpull.service /etc/systemd/system/ > sudo vim /etc/systemd/system/ghpull.service > sudo systemctl enable ghpull.service > sudo systemctl start ghpull.service