本文介绍了通过GitHub webhook将本地代码同步到Amazon服务器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在关注,从GitHub中取出新代码,然后重新部署。有,有很多可能的尝试。


I am following a tutorial on deploying a Node.js app onto the Amazon service with GitHub's webhook.

On the Amazon server, I have created a repository named hook, and initialized it as a GitHub repository

$ mkdir hook
$ cd hook
$ git init --bare

Then I created a githook

$ cat > hooks/post-receive

GIT_WORK_TREE=/home/ubuntu/myapp git checkout -f
echo "Installing dependencies..."
cd /home/ubuntu/myapp
npm install
echo "Restarting node.js..."

$ chmod +x hooks/post-receive

I think this is done on the server side, so I go back to the GitHub repository and add a WebHook URL. But I don't know how to fill in this URL, so I input

ssh://[email protected]/home/ubuntu/hook

which I think it is not right.

I commit and push my local repository on Windows platform, so as expected nothing is received on the Amazon server side.

I think it is probably due to the wrong webhook URL input at the GitHub repository setting, what do you think?

Do I have to set up a server with a URL in order to receive the updates and execute the bash?

解决方案

Your AWS server's post-receive git hooks will be executed when commits are pushed to that server:

# On your development machine
git remote add aws ssh://[email protected]/home/ubuntu/
git push aws master

GitHub's web hooks work by sending an HTTP POST request to the URL that you provide when you push new commits to GitHub. If you want your site to be updated automatically when you push code to GitHub, you need one more piece: an HTTP server running on your machine that will accept the webhook payload, pull the new code from GitHub, and then redeploy. There's another question that has a bunch of possiblities you might try.

这篇关于通过GitHub webhook将本地代码同步到Amazon服务器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 17:26