Skip to content

Instantly share code, notes, and snippets.

@wilcorrea
Last active November 24, 2020 11:03
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilcorrea/62175ff0b15fc4d8e2f06471dcf79587 to your computer and use it in GitHub Desktop.
Save wilcorrea/62175ff0b15fc4d8e2f06471dcf79587 to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
DIR_NAME=$(dirname $(readlink -f ${0}))
APP="$(dirname $(readlink -f "${DIR_NAME}/.."))/app"
REPO="$(dirname ${DIR_NAME})"
BRANCH="main"
while read oldrev newrev ref
do
BRANCH=`echo $ref | cut -d/ -f3`
echo "[1/5] Capture the name of the pushed branch"
done
cd ${APP}
echo "[2/5] Stop docker-compose before checkout the new code"
if [[ -f docker-compose.yml ]]
then
docker-compose down
fi
cd ${REPO}
echo "[3/5] Checkout the new code"
GIT_WORK_TREE="${APP}" git checkout -f ${BRANCH}
cd ${APP}
echo "[4/5] Start docker-compose after checkout"
if [[ -f docker-compose.yml ]]
then
docker-compose up -d
fi
echo "[5/5] Executes configuration commands after the containers go up"
# Add configuration commands
# ex.: docker-compose exec my-app-nginx composer install
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment