The Next Generation Platform is Coming - Get Ready Now!
GitHub Readme.md
Run custom commands during the build process.
This buildpack allows to execute arbitrary commands on the build dyno during the build process by running one or more user-supplied Bash scripts.
Add the buildpack to your app:
heroku buildpacks:add https://github.com/weibeld/heroku-buildpack-run
Create the file buildpack-run.sh
in the root directory of your app. For example:
# This is buildpack-run.sh
echo "Hello World"
Now push your app to Heroku as usual. The buildpack-run.sh
script will be run by Bash during the build.
Note that it is not required to add a #!/bin/bash
to your script (but if it's there, it doesn't do any harm).
If you want to use a script with a different name than buildpack-run.sh
, then you can specify this file in the Heroku app config variable BUILDPACK_RUN
.
For example, if your script is called script.sh
:
heroku config:set BUILDPACK_RUN=script.sh
The specified value must be a filename relative to the root directory of your app, so it could also be something like bin/script.sh
or ./script.sh
.
Note that the BUILDPACK_RUN
config variable takes precedence over the default buildpack-run.sh
file. So, if you have both, a BUILDPACK_RUN
variable and a buildpack-run.sh
file, then only the file in BUILDPACK_RUN
will be executed.
You can specify multiple files in BUILDPACK_RUN
by separating them with colons:
heroku config:set BUILDPACK_RUN=script1.sh:script2.sh:script3.sh
The scripts will be executed sequentially in the specified order.
You can specify arguments to your scripts, just as you would on the command line.
For, example, you can do something like this:
heroku config:set BUILDPACK_RUN="script1.sh 1 2 3:script2.sh hey 'hello world'"
And this will execute bash script1.sh 1 2 3
and then bash script2.sh hey 'hello world'
.
The following variables holding information about the Heroku build environment are accessible to your scripts:
BUILD_DIR
: absolute path of your app's root directory on the build dynoCACHE_DIR
: directory on the build dyno that persists between buildsENV_DIR
: directory containing files for the app's Heroku config variablesThe working directory for your scripts is BUILD_DIR
, which is the root directory of your app.
Licensed under the MIT License. See LICENSE.md file.
Copy the snippet above into CLI.
We use three kinds of cookies on our websites: required, functional, and advertising. You can choose whether functional and advertising cookies apply. Click on the different cookie categories to find out more about each category and to change the default settings.
Privacy Statement
Required cookies are necessary for basic website functionality. Some examples include: session cookies needed to transmit the website, authentication cookies, and security cookies.
Functional cookies enhance functions, performance, and services on the website. Some examples include: cookies used to analyze site traffic, cookies used for market research, and cookies used to display advertising that is not directed to a particular individual.
Advertising cookies track activity across websites in order to understand a viewer’s interests, and direct them specific marketing. Some examples include: cookies used for remarketing, or interest-based advertising.