Deploy via Git Once you’ve added your app “appname” under “appuser”, we can create a git repository on the server which will deploy the app once pushed to.
Log in as appuser. Create the git repo:
mkdir -p ~/repo/appname.git
cd ~/repo/appname.git
git init --bare
Next, create a post-receive script
vi hooks/post-receive
Add in the following, editing appname:
#!/bin/bash
export GIT_WORK_TREE=/srv/users/appuser/apps/appname
export SITE="App Name"
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [ "$branch" ] ; then
git checkout -f $branch
fi
done
echo "Deployed to $GIT_WORK_TREE"
cd $GIT_WORK_TREE
## other post-deploy commands
# composer install
# bin/appdeploy.sh
Make it executable:
chmod a+x hooks/post-receive
To push to live, add a remote locally (on your working copy):
git remote add live ssh://username@remote_address/srv/users/username/repo/appname.git
The push live with:
git push live master
Post deploy scripts should take care of the installing and script building