Add shared workflow for Heroku container deploys#42
Conversation
|
Here's some feedback in form of a PR: #43 |
|
Do we need to support multiple targets? |
|
Ah, it is the Heroku targets ( |
|
Question is, is it important for Heroku to receive the push for each process type, or is one just enough, and |
|
I renamed |
When you push to Heroku's container registry, the
We need to build each target separately
I renamed process-types back to targets since that's what you're passing: Dockerfile build targets. And moved the |
|
What was the reason for not using |
|
Should we have a established way build and push outside of Github Actions, in the case GitHub Actions is unavailable? Today it is as simple as |
That would be an argument for not using any actions in the workflow? Outsource everything to a shell script that is possible to run elsewhere (developer machine?) |
|
Good idea. The GHA-specific bits (layer caching, login-action, setup-buildx) wouldn't transfer anyway, so a local fallback would be simpler: just |
Right, I got that same above answer from my 🤖 too but then I made it use EDIT: I guess what is lost is in that change is |
Right, but that's exactly what caused the worker-starts-Puma bug? Multiple tags on one build = one image with one |
I think we should construct it now? |
Yes updated my comment #42 (comment) |
Builds Docker images in CI and pushes to Heroku's container registry. Companion to heroku.yml (git-push) for repos using container stack. Inputs: heroku-app, branch, targets (Dockerfile build targets) Secrets: heroku-key, build-args (for private dependency auth)
* Use docker actions for buildx caching and secure login Replace raw docker login with docker/login-action for secure secret handling, add docker/setup-buildx-action for BuildKit with GHA layer caching, and switch to docker buildx build --push with cache flags. Removes the standalone --target build warmup step since the GHA cache handles shared layer reuse across targets. * Build once and push to all process types Single docker buildx build with multiple -t flags instead of building per target. Rename targets input to process-types to reflect what they actually are (Heroku process types, not Dockerfile targets). * Pass RUBY_VERSION build arg from .ruby-version file if present * Bump actions so Node.js 24 is used https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/ * Use docker/build-push-action instead of shell docker buildx build * Fix build-args passing and add context to build-push-action Construct build-args as a multiline step output instead of mixing expressions with YAML block scalars. Add context: . to use the local checkout instead of git context. * Disable provenance attestation for Heroku registry compatibility Heroku's container registry doesn't support OCI manifest lists that buildx creates when provenance attestations are enabled.
Single-build-multiple-tag pushed the same image (same CMD) to all process types, causing e.g. worker to start Puma instead of its own command. Build with --target per process type so each image gets the CMD from its Dockerfile stage.
The shared workflow should be language-agnostic. Repos that need RUBY_VERSION can pass it via build-args in their own deploy workflow.
Same build logic as the workflow but without GHA-specific bits (layer caching, login-action). Run from a developer machine with docker, heroku CLI, and HEROKU_API_KEY.
Scans for .*-version files (e.g. .ruby-version, .node-version) after checkout and passes them as --build-arg flags. This lets Dockerfiles use ARG RUBY_VERSION (or similar) without callers having to explicitly pass the version.
730c74e to
85dd164
Compare
642b712 to
20af4ac
Compare
- Pin actions to SHA hashes (checkout, login-action, setup-buildx) - Fix template injection: move inputs/context to env vars - Use jq --arg for safe JSON construction - Convert build_arg_flags from string to bash array - Map cancelled job status to error for deployment API - Guard deployment status step on DEPLOYMENT_ID existence - Add persist-credentials: false to checkout
20af4ac to
526c07f
Compare
Summary
Shared reusable workflow for repos using Heroku container stack. Builds Docker images in CI and pushes to Heroku's private container registry.
Companion to
heroku.yml(git-push deploys) for repos that have been containerized.Interface
Inputs:
heroku-app— Heroku app name (defaults to repo name)branch— branch to deploy (defaults to default branch)targets— space-separated Dockerfile build targets (required)Secrets:
heroku-key— Heroku API key (required)build-args— newline-separated KEY=VALUE pairs fordocker build --build-arg(optional)Usage
Test plan