Skip to content

Instantly share code, notes, and snippets.

@shingara
Created February 9, 2016 08:39
Show Gist options
  • Save shingara/b925060b091c984d10aa to your computer and use it in GitHub Desktop.
Save shingara/b925060b091c984d10aa to your computer and use it in GitHub Desktop.
!/bin/bash
if [[ $# -eq 0 ]] ; then
echo 'define a branch to deploy'
exit 0
fi
echo "deploy branch $@"
BRANCH=$@
REMOTE_STAGING_IP=
PROJECT=
GIT_URL=
BRANCH_PROJECT=$PROJECT-$BRANCH
mkdir -p tmp/deploy
cd tmp/deploy
if [ ! -d "$DIRECTORY" ]; then
git clone $GIT_URL
fi
cd $PROJECT
git checkout master
git reset --hard origin/master
git checkout $BRANCH
git reset --hard origin/$BRANCH
git pull origin $BRANCH
git remote add dokku-$BRANCH ssh://dokku@$REMOTE_STAGING_IP/$BRANCH_PROJECT
echo "Configure ENV variable"
./bin/dokku-staging config:set --no-restart $BRANCH_PROJECT `./bin/dokku-staging config $PROJECT --shell`
./bin/dokku-staging config:set --no-restart $BRANCH_PROJECT POSTGRESQL_DATABASE_DEV=t4b_staging POSTGRESQL_DATABASE_OLD_DEV=t4b_staging
git push dokku-pr -f $BRANCH:master
./bin/dokku-staging ps:stop $BRANCH_PROJECT
./bin/dokku-staging run $BRANCH_PROJECT rake db:copy_and_migrate
./bin/dokku-staging ps:start $BRANCH_PROJECT
#!/bin/bash
DOKKU_URL=
ssh -t dokku@$DOKKU_URL "$*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment