Skip to content

Instantly share code, notes, and snippets.

@madx
Last active August 3, 2022 10:09
Show Gist options
  • Save madx/6063738 to your computer and use it in GitHub Desktop.
Save madx/6063738 to your computer and use it in GitHub Desktop.
Git aliases for a simple tag based Heroku deploy strategy
[alias]
deploy = ! git checkout master && git tag-deploy && git push && git push --tags && git push production master
deploy-staging = ! git checkout develop && git tag-deploy staging && git push && git push --tags && git push staging develop:master
tag-deploy = ! sh -c 'git tag "${0:-production}-`date +%Y%m%d%H%M%S`-$USER"'

Tagged Heroku deploys

Here is a strategy and some useful Git aliases to ease deploying applications on Heroku using tags for further reference.

Why tags?

Tags are useful because they convey informations about when you deployed and who did it.

When you pull from a repo, you immediately see who and when the code you are pulling has been deployed.

It is also useful to quickly get back to a given reference point.

Prerequisites

In the following aliases, we assume that master is your production-ready branch, and develop the place where main development happens (this is the code that gets deployed on your staging host)

We also have two remotes set-up: production and staging. They both point to Heroku apps repos, and I guess you understand their respective roles,

It's useful though to point out that for the staging environment, you have to force the develop branch to be pushed on master for Heroku.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment