Using env variables in release_command

Migrating an app from Heroku with Turboku and ran into some unexpected behavior with the release_command not interpolating env variables ($VAR_NAME) and passing the var string as is to the command (e.g. “$DATABASE_URL” instead of “postgres://…”).

The fix was to wrap the command in a bash one liner.

[deploy]
  release_command = "migrate --path db/migrate --url $DATABASE_URL --timeout 300 up"

Wrap the command in a bash -c '' block.

[deploy]
  release_command = "bash -c 'migrate --path db/migrate --url $DATABASE_URL --timeout 300 up'"
1 Like