Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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://ubuntu@54.201.12.68/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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
174 views
Welcome To Ask or Share your Answers For Others

1 Answer

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 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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...