Reputation: 41040
Can I deploy directly from GitHub to my (debian linux) server? Is there a way of transmitting code from GitHub to my server automatically after each commit? And also manipulating a config file?
Upvotes: 0
Views: 327
Reputation: 485
Bibhas' answer above is correct although, if you're not the only person collaborating on the repository, you may want to consider using git tags to indicate release-able code and trigger the update only when a new tag appears.
To do this, tag your latest commit on your dev machine and push it:
git tag -a v1.0 -m"Initial tag"
git push origin --tags
Then, on your server:
git remote update && git checkout v1.0
Then, your cron script should do the following:
cd $REPO && git remote update
HEAD
(assumes you are ONLY checking out to tags):current=$(git rev-parse HEAD)
latest=$(git rev-list --tags | head -1)
$current
is not equal to $latest
, check out the latest tag:git checkout $(git tag --points-at $latest)
Upvotes: 1
Reputation: 14929
Clone the repository on server, Run a cronjob on the server every 1 or 2 minutes(or any interval depending on the frequency of your commits) and update the repo. That should be enough. But that's not advisable on the production server. You could do it on testing or staging server though.
Upvotes: 2