Last active
April 18, 2016 08:47
-
-
Save sweikenb/9e581e00f1c366f61cbbd6de8ec7ef64 to your computer and use it in GitHub Desktop.
Dimple GIT deployment for symfony apps
This file contains hidden or 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/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; |
This file contains hidden or 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
# 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