Skip to content

Instantly share code, notes, and snippets.

@johnRivs
Last active December 31, 2017 17:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnRivs/66fe101c35a28c089454 to your computer and use it in GitHub Desktop.
Save johnRivs/66fe101c35a28c089454 to your computer and use it in GitHub Desktop.
Deployment workflow

Step 1

Let's say you have a remote user www, your server is domain.com and your app is myapp:

www@domain.com:~$ mkdir myapp repo/myapp.git
www@domain.com:~$ cd repo/myapp.git
www@domain.com:/home/www/repo/myapp.git$ git init --bare
www@domain.com:/home/www/repo/myapp.git$ touch hooks/post-receive
www@domain.com:/home/www/repo/myapp.git$ chmod +x hooks/post-receive

Step 2

Add this to /home/www/repo/myapp.git/hooks/post-receive:

#!/bin/sh
git --work-tree=/home/www/myapp --git-dir=/home/www/repo/myapp.git checkout -f
# Here you would also add stuff like npm install if you need.
# cd /home/www/myapp
# npm install --only=prod
# composer install --no-dev

Step 3

Add the remote:

git remote add origin ssh://www@domain.com/home/www/repo/myapp.git

Make some changes, commit the changes and push them:

git push origin master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment