我正在关注部署的教程使用GitHub的webhook将Node.js应用程序加载到Amazon服务上。
在Amazon服务器上,我创建了一个名为hook的存储库,并将其初始化为GitHub仓库 $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $
然后我创建了一个githook
$ cat> hooks / post-receive GIT_WORK_TREE = / home / ubuntu / myapp git checkout -f echo安装依赖关系... cd / home / ubuntu / myapp npm install echoRestarting node.js ... $ chmod + x hooks / post-receive我认为这是在服务器端完成的,所以我回到GitHub存储库并添加一个WebHook URL。但我不知道如何填写这个网址,所以我输入
ssh://ubuntu@54.201.12.68/ home / ubuntu / hook我认为这是不正确的。
我在Windows平台上提交并推送本地存储库,因此预计Amazon服务器端不会收到任何内容。
我认为这很可能由于在GitHub存储库设置中输入了错误的webhook URL,您认为什么?
为了接收更新,我必须使用URL设置服务器吗?并执行bash?
解决方案当提交到服务器时,您的AWS服务器的post-receive git钩子将被执行:
#在你的开发机器上 git remote add aws ssh://ubuntu@54.201.12.68/home/ubuntu/ git push aws masterGitHub的Web挂钩通过发送HTTP POST请求到URL你脓的时候提供的h新的提交给GitHub。如果您希望在将代码推送到GitHub 时自动更新您的站点,则需要更多的部分:在您的机器上运行的HTTP服务器,它将接受 webhook有效负载,从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 --bareThen 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-receiveI 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://ubuntu@54.201.12.68/home/ubuntu/hookwhich 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://ubuntu@54.201.12.68/home/ubuntu/ git push aws masterGitHub'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服务器
发布评论