Reputation: 74
I want to configure an automatic deployment of my Symfony website directly from git to my ovh server (Performance offer - with SSH access).
I followed these ovh instructions : https://docs.ovh.com/fr/fr/web/hosting/24-days/day07/
created a post-receive file at $HOME/depot_git_beta/hooks
#!/bin/bash
# Hook post-receive
# Force source bash profile to update PATH
source ~/.bash_profile
source ~/.bashrc
GIT_REPO=$HOME/depot_git_beta
DEPLOY_DIR=$HOME/beta
# Go to deploy directory to load ovhconfig
cd $DEPLOY_DIR
ovhConfig
cd -
while read prevsha1 newsha1 ref
do
if [[ $ref =~ .*/develop$ ]];
then
echo "Deploying develop branch to beta..."
git --work-tree=$DEPLOY_DIR --git-dir=$GIT_REPO checkout -f
cd $DEPLOY_DIR
# Install vendors
composer install --no-dev --no-interaction
echo "Vendors updated!"
# Update database
php bin/console doctrine:schema:update --force
echo "Database for beta environment updated!"
# Clear cache
php bin/console cache:clear --env=dev
php bin/console cache:clear --env=prod
echo "Cache cleared!"
else
echo "Ref: $ref isn't develop. Nothing to do on beta"
fi
done
add the distant repository
git remote add ovh [email protected]:depot_git_beta
but when I do git push ovh develop
it does seems to work, git bash tells it's up to date, but nothing seems to have happened in ovh server.
Any idea what went wrong or where I should look first ?
Upvotes: 3
Views: 1249
Reputation: 74
The problem was essentially that as I was not deploying the master branch, I had to precise it in this line:
$ git --work-tree=... --git-dir=... checkout -f develop
See this very helpful answer!
(And thank you piarson for helping me to find the solution!)
Upvotes: 1