Alas, I don't recommend starting any new projects on Heroku. You should probably move to Render, Fly, Railway or any other alternative. Cheers
Get a Heroku CI badge for your repo's README file.
- A Heroku app
- A Heroku Pipeline configured for that app
- Use Heroku CI for that pipeline
During the setup, you will be asked to fill out two environment variables:
Generate a token using
heroku authorizations:create -s "read" -S -d "heroku-ci-badge"
This should be the UUID of the pipeline to which Heroku CI is attached (9478101b-...
) rather than the name of the pipeline (myapp-pipeline
).
You will be redirected to /last.svg
, the URL for the dynamic badge.
[![Heroku CI Status](https://{deployed app name}.herokuapp.com/last.svg)](https://dashboard.heroku.com/pipelines/{pipeline ID}/tests)
Change how frequently the build result badge refreshes by setting the CACHE_TIMEOUT
environment var (in seconds). The default value is 15 minutes.
heroku config:set CACHE_TIMEOUT="300" -a {deployed app name}
Note that a shorter cache period will result in more calls to the Heroku API, which may lead to elevated errors.
Setting CACHE_TIMEOUT
to 0
is strongly discouraged.
If you're seeing...
... instead of a pass/fail mark, it means that the heroku-ci-badge app could not retrieve the build status.
- Check that you've set the
HEROKU_AUTH_TOKEN
environment variable on your app - Check that your auth token is valid by running
heroku authorizations
. Note that token IDs (shown in the list) and the token values are not the same. Do you see the "heroku-ci-badge" token generated previously? If you runheroku authorizations:info {token id}
is theToken: {token value}
value the same as the one you set as theHEROKU_AUTH_TOKEN
environment variable? - Check that you've set the
PIPELINE_ID
environment variable on your app - Check that the
PIPELINE_ID
value is valid by checking the pipeline URLhttps://dashboard.heroku.com/pipelines/{pipeline ID}
- Check the app's log outputs for errors:
heroku log -a {deployed app name}
If you're seeing...
... it means that:
- the image URL might be wrong (check the public URL to your deployed app, and that you're referencing
/last.svg
) - your heroku-ci-badge app might be sleeping if you're using a Free Dyno. See here: "If an app has a Free web dyno, and that dyno receives no web traffic in a 30-minute period, it will sleep". Upgrade the dyno type to
hobby
(7$/month) to remedy.
Updating the app's code once it's deployed is not as easy as doing the initial deployment (i.e., it's not a single click). Based on the instructions here, here are the steps to update deployed heroku-ci-badge
apps:
# instructions for the first update only (see below for further updates)
cd {some directory}
git init
heroku git:remote -a {deployed app name}
git remote add origin https://github.com/gregsadetsky/heroku-ci-badge
git pull origin master
git push heroku master
For further updates:
git pull origin master
git push heroku master
- Support more than 1 pipeline (use /pipelines/{ID}/x.svg ?)
- Support master and other branches (use /{branch}.svg and /pipelines/{branch}.svg ?)
- Dogfood: use Heroku CI & show badge for this app
- Shields.io for the shield svg.
- Ismar Slomic for the question & motivation.
- Franz Geffke for the instructions on updating a Heroku app after it was deployed using a "Deploy to Heroku" button.
- Heroku, for being awesome.
- This software is provided as is.
- This project has no affiliation with Heroku.