Skip to content

Instantly share code, notes, and snippets.

@sweikenb
Last active April 18, 2016 08:47
Show Gist options
  • Save sweikenb/9e581e00f1c366f61cbbd6de8ec7ef64 to your computer and use it in GitHub Desktop.
Save sweikenb/9e581e00f1c366f61cbbd6de8ec7ef64 to your computer and use it in GitHub Desktop.
Dimple GIT deployment for symfony apps
#!/bin/bash
#
# Example and very basic deplosy script
#
# change to the right directory
cd /path-to-project-root;
# Remove unsecure files
rm web/app_dev.php web/config.php
# composer installed?
if [ ! -f "composer.phar" ]; then
curl -sS https://getcomposer.org/installer | php
else
php composer.phar selfupdate
fi
# Vendors
echo; echo "Installing vendors ...";
php composer.phar install -o
# cache cear (for symfony 3+ apps use "bin/console" instead of "app/console")
php app/console cache:clear --env=prod
php app/console assets:install web --symlink --env=prod
php app/console assetic:dump --env=prod
# Done
echo; echo "Deploy done!"; echo;
# 1. create deploy directory on target server
mkdir workingdir
mkdir deploy.git
cd deploy.git
# 2. initialize "bare" repository
git init --bare
git config core.bare false
git config core.worktree "../workingdir/"
git config receive.denycurrentbranch ignore
git --bare update-server-info
# 3. create deoploy trigger by hooks
nano hooks/post-receive
# 3.1 paste code into file:
#!/bin/bash
read oldrev newrev ref
git checkout -f $newrev
chmod +x /absolute-path-to/workingdir/deploy.sh
/absolute-path-to/workingdir/deploy.sh $oldrev $newrev $ref
# 3.2 make script executable:
chmod +x hooks/post-receive
# 4. add git remote
git remote add deploy user@hostname:deploy.git
# 4.1 push code to remote
git push deploy master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment