https://github.com/pbrisbin/heroku-build
Interact with the Heroku Build API
https://github.com/pbrisbin/heroku-build
Last synced: 6 months ago
JSON representation
Interact with the Heroku Build API
- Host: GitHub
- URL: https://github.com/pbrisbin/heroku-build
- Owner: pbrisbin
- License: bsd-3-clause
- Created: 2014-06-03T00:28:02.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2017-05-06T01:43:31.000Z (over 8 years ago)
- Last Synced: 2025-01-03T16:30:06.231Z (12 months ago)
- Language: Haskell
- Homepage:
- Size: 20.5 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# heroku-build
Interact with the Heroku Build API to start builds, check the status of
builds, or release built slugs to other applications.
## Installation
```
% stack install
% heroku-build --help
```
## Prerequisites
You'll need to set the `HEROKU_API_KEY` environment variable. You can
probably find a suitable value in your `~/.netrc`.
You should either `export` this value:
```
% export HEROKU_API_KEY="..."
```
Or prefix each call explicitly:
```
% HEROKU_API_KEY="..." heroku-build ...
```
## Usage
**start**
Initiate a build of version 1 (*v1*) of *my-app*'s sources on a
*my-compile* Heroku instance. This call will return a *build id*, which
you will need for subsequent calls.
```
% heroku-build --app my-compile start http://example.com/my-app.tar.gz v1
abcd-abcdabcdabcd-abcd
```
*NOTE*: The sources must be reachable by Heroku. For private GitHub
repos, you'll need to include an access token in the URL. You can
generate a Personal OAuth Token via your account settings page.
**status**
Check the progress of the build:
```
% heroku-build --app my-compile status abcd-abcdabcdabcd-abcd
pending
```
Eventually (hopefully), it will succeed:
```
% heroku-build --app my-compile status abcd-abcdabcdabcd-abcd
succeeded
```
**release**
Release the slug to your production application (called *my-prod* here):
```
% heroku-build --app my-compile release abcd-abcdabcdabcd-abcd my-prod
Success
```
## Automation
This process is meant to be scripted. Below is a simple example:
```sh
#!/bin/sh
set -e
HEROKU_API_KEY="..."
compile_app="..."
release_app="..."
sources="..."
status="pending"
version="$(git rev-parse --short HEAD)" # short sha
build_id="$(heroku-build --app "$compile_app" start "$sources" "$version")"
while [ "$status" = 'pending' ]; do
printf '.'
status="$(heroku-build --app "$compile_app" status "$build_id")"
done
printf "\n"
[ "$status" = 'succeeded' ] && \
heroku-build --app "$compile_app" release "$build_id" "$release_app"
```