Questions check out the original here: https://gist.github.com/thomasfr/9691385
-
We use the user account created in cpanel.
-
Use the SSH public key used to connect via Putty and FTP.
-
Create a
git bare
repo for your project:
cd /home/appAccount/var/git
$ mkdir AppName
$ cd AppName
## /home/git/testapp
$ git init --bare
- Copy the
post-receive
script from this gist to thehooks
dir of the created bare repo.
$ vim AppName/hooks/post-receive
## Paste the post-receive script from this gist and save
## If you do not need to execute a 'build' and/or 'restart' command,
## just delete or comment the lines 'UPDATE_CMD' and 'RESTART_CMD'
$ chmod +x testapp/hooks/post-receive
- Set ownership and permissions of the
DEPLOY_ROOT
directory manually.
Set Octal to 0775
- Create a git repo and add our newly created
remote
:
$ mkdir testapp
$ cd testapp
$ git init
$ git remote add deploy SSH://username@serveripaddress:22/home/appdirectory/repositorydirectory
ex. ssh://pinkstra@199.168.173.244:22/home/pinkstra/var/git/PinkStrands
- Check remote locations to make sure it added
deploy
successfully:
git remote -v
- Pull from master and push to production:
$ git checkout master
$ git pull
$ git push deploy master
pinkstra@199.168.173.244's password:
stdin: is not a tty
Counting objects: 231, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (97/97), done.
Writing objects: 100% (231/231), 205.67 KiB | 0 bytes/s, done.
Total 231 (delta 158), reused 158 (delta 126)
remote: hooks/post-receive: line 48: ip: command not found
remote: githook: Tue May 3 15:13:31 CDT 2016: Welcome to 'server.donnabellahairextensions.com' ()
remote:
remote: githook: I will deploy 'master' branch of the '' project to '/home/pinkstra/var/git/PinkStrands'
remote: Already on 'master'
remote: HEAD is now at 3cc2567 fixed encrypted file decrypt by adding .travis 2
remote:
remote: githook: Tue May 3 15:13:34 CDT 2016: See you soon at 'server.donnabellahairextensions.com' ()
To ssh://pinkstra@199.168.173.244:22/home/pinkstra/var/git/PinkStrands
* [new branch] master -> master
- Repeat: Develop, test, commit and push :)
cd localmachine/AppDirectory
git pull
git push deploy master
**Enter SSH Passphrase**
Congratulations, you just setup git push deployment with automated build and service restart