Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: Build and publish container image

on:
pull_request:
push:
branches:
- main
Expand All @@ -11,18 +12,25 @@ permissions:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: ${{ github.event_name == 'pull_request' }}

jobs:
checks:
if: github.event_name != 'pull_request'
uses: ./.github/workflows/ci.yml

publish:
name: Build container image (amd64)
runs-on: blacksmith-2vcpu-ubuntu-2404
timeout-minutes: 60

permissions:
contents: read
packages: write

env:
PUBLISH_IMAGE: ${{ github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }}

outputs:
digest: ${{ steps.build.outputs.digest }}

Expand All @@ -36,6 +44,7 @@ jobs:
uses: useblacksmith/setup-docker-builder@v1

- name: Log in to GitHub Container Registry
if: env.PUBLISH_IMAGE == 'true'
uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0
with:
registry: ghcr.io
Expand All @@ -47,25 +56,39 @@ jobs:
uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0
with:
images: ghcr.io/${{ github.repository }}
flavor: latest=false
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=sha-
type=sha,format=long

- name: Build and push candidate image
- name: Build candidate image
id: build
uses: useblacksmith/build-push-action@v2 # v7.3.0
with:
context: .
push: true
platforms: linux/amd64
push: ${{ env.PUBLISH_IMAGE == 'true' }}
load: ${{ env.PUBLISH_IMAGE != 'true' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

- name: Install smoke test tools
if: env.PUBLISH_IMAGE != 'true'
uses: taiki-e/install-action@742a3317eac7bd62f91cd888b4eead5e784ba833 # v2.87.1
with:
tool: just,ripgrep

- name: Test the local candidate image
if: env.PUBLISH_IMAGE != 'true'
env:
IMAGE: ${{ steps.meta.outputs.tags }}
run: just container-smoke "$IMAGE"

promote:
name: Promote the tested image
runs-on: blacksmith-2vcpu-ubuntu-2404
timeout-minutes: 10
needs: [checks, publish]
if: github.ref == 'refs/heads/main'
if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch')

permissions:
contents: read
Expand Down Expand Up @@ -98,6 +121,6 @@ jobs:

- name: Promote and record the deployment image
run: |
docker buildx imagetools create --prefer-index=false --tag "$IMAGE:stable" "$IMAGE@$DIGEST"
docker buildx imagetools create --prefer-index=false --tag "$IMAGE:stable" --tag "$IMAGE:latest" "$IMAGE@$DIGEST"

printf 'Deploy image: %s@%s\n' "$IMAGE" "$DIGEST" >> "$GITHUB_STEP_SUMMARY"
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ The `serve` command supports Sentry error reporting. Set `SENTRY_DSN` to enable

## Local development and preview

Use stable Rust. `rust-toolchain.toml` and CI select the latest stable release; the Docker builder tracks the latest Rust release on Trixie. `Cargo.lock` is included and all builds use `--locked`. CI runs separate formatting, Clippy, and test jobs on pull requests and pushes to `main`.
Use stable Rust. `rust-toolchain.toml` and CI select the latest stable release; the Docker builder tracks the latest Rust release on Trixie. `Cargo.lock` is included and all builds use `--locked`. CI runs separate formatting, Clippy, test, and container build jobs on pull requests and pushes to `main`. You can also run the container workflow manually.

```sh
just fmt
Expand All @@ -75,9 +75,11 @@ Run `just container-smoke` after `just container-build` to check non-root startu

## Container publishing

Pushing to `main` runs the [container workflow](.github/workflows/build.yml). It builds the locked Dockerfile and publishes `ghcr.io/actix/github-release-router:latest` and a `sha-<commit>` candidate tag. Formatting, Clippy, and tests run through the reusable CI workflow. After those checks and the image build pass, a separate promotion job runs `just container-smoke` against the published image digest. It then points `stable` at that same image index without rebuilding it. A failed check leaves `stable` unchanged.
The [container workflow](.github/workflows/build.yml) builds the locked Dockerfile for `linux/amd64`. Pull requests build and smoke-test a local image without publishing. Formatting, Clippy, and tests run in the CI workflow.

Deployments must follow the digest behind `ghcr.io/actix/github-release-router:stable`. Publishing a candidate alone does not select a deployment image. The workflow also supports a manual run on `main`; runs on other branches cannot promote `stable`.
Each push to `main` publishes a `ghcr.io/actix/github-release-router:sha-<full-commit>` candidate and runs formatting, Clippy, and tests through the reusable CI workflow. After those checks and the image build pass, the promotion job runs `just container-smoke` against the published image digest. It then updates `:stable` and `:latest` to that exact digest without rebuilding the image. A failed check leaves the deployment tags unchanged.

Deployments must follow the digest behind `ghcr.io/actix/github-release-router:stable`, or pin the digest recorded in the promotion job summary. Publishing a candidate alone does not select a deployment image. Manual runs publish and promote only when you select `main`.

The workflow uses the repository's `GITHUB_TOKEN` with package write permission. A new GHCR package is private by default, so make it public or grant your cluster image-pull access before deploying it.

Expand Down