Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have an Amazon EC2 instance with a bare git repository containing my app. I've setup a post-receive hook that does a git checkout -f into my www. To push to this repo I've setup a remote in my local repository so I can run git push dev and everything seems to work.

The problem is that this code also exists as is on GitHub. This is a bit redundant and lacks the ability to see commit history and updates for activity going into the dev (or soon to be live) environments. Also if my EC2 setup grew into a cluster, I don't think it would be possible to run git push dev and push to multiple repos in the cluster.

GitHub has several https post hooks that can tell my server that someone has committed. My question is, what is the best way to do this while not compromising security, or dependency on the application I am pushing to. For example if the application is unavailable, I still want to be able to deploy.

If the url is impossible to guess, say https://myserver.com/SOME_RANDOM_TOKEN, is that enough to prevent anything malicious? I would like to avoid having to implement auth for this post-recieve URL.

How should configurations be setup since there won't be an easy way to push something to the server separately from the repository? What should the branches look like?

Any answers or suggestions on these would be very helpful. Thanks in advance.

share|improve this question

migrated from stackoverflow.com Jun 13 '11 at 10:18

This question came from our site for professional and enthusiast programmers.

    
Server fault would be better suited for this kind of question –  Jahufar Jun 13 '11 at 4:40
    
Why not have two branches in one repo? When we need to deploy our apps we push stuff into the 'DEPLOY' branch which triggers the hook to deploy on the servers –  sam Jun 13 '11 at 10:22
    
We already have multiple branches for dev, qa, live, and master. –  Skawful Jun 13 '11 at 22:37
add comment

1 Answer

You can setup a post-commit hook on Github, but it's going to have much the same problems that you identified with git push dev -- Github's only going to hit one URL, and that isn't going to work (directly) with a cluster.

I'd recommend not looking for the "smart" way, but instead going with the tried-and-true, simple method of a deployment script that does the necessary pushing/pulling/kicking/whatever's required to all machines that need it. Deployment frameworks like Capistrano, Vlad the Deployer, and a host of other options (available in your choice of languages) make life easier in the common case, but even a simple shell script will significantly improve your workflow.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.