Last active
June 19, 2017 14:09
-
-
Save gboddin/b6578da6660d1b68d5b709e61050a9b1 to your computer and use it in GitHub Desktop.
docker-compose branch git post-checkout plugin
This file contains 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/sh | |
# Place me in .git/hooks/post-checkout | |
# Gets name from previous branch | |
PREVIOUS_BRANCH=$(git name-rev --name-only $1) | |
# Gets name from current branch | |
CURRENT_BRANCH=$(git name-rev --name-only $2) | |
if [ "${PREVIOUS_BRANCH}" != "${CURRENT_BRANCH}" ]; then | |
echo "Coming from ${PREVIOUS_BRANCH} to ${CURRENT_BRANCH}" | |
export PREVIOUS_NAME=$(basename `pwd`)_${PREVIOUS_BRANCH} | |
export PROJECT_NAME=$(basename `pwd`)_${CURRENT_BRANCH} | |
echo "COMPOSE_PROJECT_NAME=${PREVIOUS_NAME}" > .env | |
docker-compose stop | |
echo "COMPOSE_PROJECT_NAME=${PROJECT_NAME}" > .env | |
docker-compose up -d | |
fi | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment