Setting multiple pipeline env vars for review apps on Heroku

Overview

Heroku doesn’t seem to support setting env vars on the actual review app pipeline via the CLI, so to set in bulk, you can either add them to your app.json or manually add them via the dashboard.

This can be a pain if you have a bunch of variables you don’t want to include in your repo (api keys, secrets, etc).

Luckily, you can abuse the platform api and set these env vars via curl:

curl -X PATCH -H "content-type: application/json; charset=UTF-8" -H "accept: application/vnd.heroku+json; version=3.pipelines" -H "authorization: Bearer <YOUR BEARER TOKEN>" -d '{
"MY ENV VAR": "SOME VALUE",
"MY ENV VAR 2": "SOME VALUE 2"
}' https://api.heroku.com/pipelines/<YOUR PIPELINE ID>/stage/review/config-vars