Skip to content

Instantly share code, notes, and snippets.

@caarlos0
Last active December 18, 2017 01:00
Show Gist options
  • Save caarlos0/6366804 to your computer and use it in GitHub Desktop.
Save caarlos0/6366804 to your computer and use it in GitHub Desktop.
Continous deploy with Jenkins and Heroku. This is the post-build script.
#!/bin/bash
#
# login in the jenkins server with:
#
# heroku login
# heroku keys:add
#
# Doing so, jenkins will have permission to deploy to
# the heroku remote.
#
# exit 1 on errors
set -e
# deal with remote
echo "Checking if remote exists..."
if ! git ls-remote heroku; then
echo "Adding heroku remote..."
git remote add heroku git@heroku.com:PROJECT.git
fi
# push only origin/master to heroku/master - will do nothing if
# master doesn't change.
echo "Updating heroku master branch..."
git push heroku origin/master:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment