Skip to content

Instantly share code, notes, and snippets.

@jlecour
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jlecour/6baaeca6fbd911569f67 to your computer and use it in GitHub Desktop.
Save jlecour/6baaeca6fbd911569f67 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
[ -n "$DEBUG" ] && set -x
CAP_BIN="bin/cap"
CAP_COMMAND="${CAP_BIN} production"
# git name-rev is fail
CURRENT=`git branch | grep '\*' | awk '{print $2}'`
TIMESTAMP=`date +"%s"`
TAG="prod-${TIMESTAMP}-${USER}"
if [ "master" = "${CURRENT}" ]
then
# une branche "production" est (re)initialisée sur le commit courant
git branch -f production
# … et poussée sur le remote "origin"
git push --force origin production
# et le déploiement a lieu
if [ "${MIGRATE}" == '1' ]; then
$CAP_COMMAND deploy:migrations
else
$CAP_COMMAND deploy
fi
# création du tag
git tag ${TAG} && git push origin tag ${TAG}
else
echo "Impossible de passer en production sans être sur 'master'"
exit 1
fi
#!/bin/sh
set -e
[ -n "$DEBUG" ] && set -x
CAP_BIN="bin/cap"
CAP_COMMAND="${CAP_BIN} staging"
git branch -f staging
git push --force origin staging
if [ "${MIGRATE}" == '1' ]; then
$CAP_COMMAND deploy:migrations
else
$CAP_COMMAND deploy
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment