Last active
August 1, 2018 03:25
-
-
Save pmanijak/8047140 to your computer and use it in GitHub Desktop.
Setting up a simple auto-deploy with git on Linux
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On server | |
----------------- | |
# make a git repo | |
$ mkdir /path/to/repo.git | |
$ cd /path/to/repo.git | |
$ git init --bare | |
# make a post-receive hook | |
# see the post-receive file in this Gist | |
# if you're using Node.js | |
$ cat > hooks/post-receive | |
#!/bin/sh | |
GIT_WORK_TREE=/path/to/deploy git checkout -f | |
^D | |
$ chmod +x hooks/post-receive | |
# make the deploy directory | |
$ mkdir /path/to/deploy | |
On client | |
----------------- | |
# make your repo | |
# ... | |
# add a remote to it that points to the server | |
$ git remote add deploy ssh://user@server.example.org/path/to/repo.git | |
# first push | |
$ git push deploy +master:refs/heads/master | |
# done | |
$ git push deploy | |
-- | |
Adapted from: http://toroid.org/ams/git-website-howto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# This is a post-receive hook for a Node.js app using | |
# Webfaction's quick-install as a starting point. | |
APP_DIR=/path/to/deployed/app | |
${APP_DIR}/bin/stop | |
GIT_WORK_TREE=${APP_DIR}/src git checkout -f | |
${APP_DIR}/bin/npm install ${APP_DIR}/src/app | |
cd ${APP_DIR} | |
${APP_DIR}/bin/start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment