Skip to content

Instantly share code, notes, and snippets.

@maxperei
Created December 23, 2019 09:13
Show Gist options
  • Save maxperei/2985e3c629e1bafd376a18a6711e2568 to your computer and use it in GitHub Desktop.
Save maxperei/2985e3c629e1bafd376a18a6711e2568 to your computer and use it in GitHub Desktop.
craft 3 deploy ovh mutu
#!/bin/bash
set -eu
while read oldrev newrev ref
do
branch=`echo $ref | cut -d/ -f3`
if [[ "master" = "$branch" ]];
then
target="www/prod"
remote="production"
elif [[ "develop" = "$branch" ]]
then
target="www/stage"
remote="preprod"
else
echo "Branch $branch not configured to be deployed"
fi
root="/home/lecerclenu"
final="${root}/${target}"
dir="${root}/socrates.git"
echo $ref
if [[ "$ref" = "refs/heads/$branch" ]];
then
echo "Ref $ref received. Deploying ${branch} branch to ${remote} remote..."
git --work-tree=$final --git-dir=$dir checkout -f $branch
cd $final
#pwd
unset GIT_DIR
git fetch origin $branch
git reset --hard FETCH_HEAD
/usr/local/php7.2/bin/php craft update/composer-install
/usr/local/php7.2/bin/php craft clear-caches/all
/usr/local/php7.2/bin/php craft project-config/sync
/usr/local/php7.2/bin/php craft
/usr/local/php7.2/bin/php craft migrate/up
echo "Deployed!"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment