From a4efd5b00e468785699bbcd281f88478579c7fac Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 9 Oct 2026 02:24:56 +0300 Subject: [PATCH 1/3] ci: test container builds and gate deployment tags --- .github/workflows/build.yml | 60 ++++++++++++++++++++++++++++++++----- .github/workflows/ci.yml | 2 ++ README.md | 8 +++-- 3 files changed, 60 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 0a33b54..e50d339 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,9 +1,14 @@ name: Build and publish container image on: + pull_request: + merge_group: + types: [checks_requested] push: branches: - main + tags: + - "v*" workflow_dispatch: permissions: @@ -11,18 +16,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' && github.event_name != 'merge_group' 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.event_name != 'pull_request' && github.event_name != 'merge_group' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }} + outputs: digest: ${{ steps.build.outputs.digest }} @@ -36,6 +48,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 @@ -47,25 +60,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.event_name != 'pull_request' && github.event_name != 'merge_group' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) permissions: contents: read @@ -96,8 +123,27 @@ jobs: - name: Test the candidate image run: just container-smoke "$IMAGE@$DIGEST" + - name: Generate deployment tags + id: meta + uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 + with: + images: ${{ env.IMAGE }} + flavor: latest=false + tags: | + type=raw,value=stable + type=ref,event=tag + type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} + - name: Promote and record the deployment image + env: + TAGS: ${{ steps.meta.outputs.tags }} run: | - docker buildx imagetools create --prefer-index=false --tag "$IMAGE:stable" "$IMAGE@$DIGEST" + tag_args=() + + while IFS= read -r tag; do + tag_args+=(--tag "$tag") + done <<< "$TAGS" + + docker buildx imagetools create --prefer-index=false "${tag_args[@]}" "$IMAGE@$DIGEST" printf 'Deploy image: %s@%s\n' "$IMAGE" "$DIGEST" >> "$GITHUB_STEP_SUMMARY" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9868f6f..3a9b04b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,6 +2,8 @@ name: CI on: pull_request: + merge_group: + types: [checks_requested] workflow_call: permissions: diff --git a/README.md b/README.md index f64395d..8c2ff14 100644 --- a/README.md +++ b/README.md @@ -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, merge groups, pushes to `main`, and `v*` tags. You can also run the container workflow manually. ```sh just fmt @@ -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-` 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 and merge groups 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`. +Pushes to `main` and `v*` tags publish `ghcr.io/actix/github-release-router:sha-` candidates and run 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` without rebuilding the image. Successful `main` runs also update `:latest`; successful `v*` tag runs also publish the Git tag as an image tag. 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` or a `v*` tag. 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. From f946864046276a5cfab007bc6cc2d76d9e62208c Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 9 Oct 2026 02:42:48 +0300 Subject: [PATCH 2/3] ci: publish container images only from main --- .github/workflows/build.yml | 27 +++------------------------ README.md | 6 +++--- 2 files changed, 6 insertions(+), 27 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e50d339..a653aee 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -7,8 +7,6 @@ on: push: branches: - main - tags: - - "v*" workflow_dispatch: permissions: @@ -33,7 +31,7 @@ jobs: packages: write env: - PUBLISH_IMAGE: ${{ github.event_name != 'pull_request' && github.event_name != 'merge_group' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) }} + PUBLISH_IMAGE: ${{ github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') }} outputs: digest: ${{ steps.build.outputs.digest }} @@ -92,7 +90,7 @@ jobs: runs-on: blacksmith-2vcpu-ubuntu-2404 timeout-minutes: 10 needs: [checks, publish] - if: github.event_name != 'pull_request' && github.event_name != 'merge_group' && (github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v')) + if: github.ref == 'refs/heads/main' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch') permissions: contents: read @@ -123,27 +121,8 @@ jobs: - name: Test the candidate image run: just container-smoke "$IMAGE@$DIGEST" - - name: Generate deployment tags - id: meta - uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 - with: - images: ${{ env.IMAGE }} - flavor: latest=false - tags: | - type=raw,value=stable - type=ref,event=tag - type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} - - name: Promote and record the deployment image - env: - TAGS: ${{ steps.meta.outputs.tags }} run: | - tag_args=() - - while IFS= read -r tag; do - tag_args+=(--tag "$tag") - done <<< "$TAGS" - - docker buildx imagetools create --prefer-index=false "${tag_args[@]}" "$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" diff --git a/README.md b/README.md index 8c2ff14..2b89241 100644 --- a/README.md +++ b/README.md @@ -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, test, and container build jobs on pull requests, merge groups, pushes to `main`, and `v*` tags. You can also run the container workflow manually. +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, merge groups, and pushes to `main`. You can also run the container workflow manually. ```sh just fmt @@ -77,9 +77,9 @@ Run `just container-smoke` after `just container-build` to check non-root startu The [container workflow](.github/workflows/build.yml) builds the locked Dockerfile for `linux/amd64`. Pull requests and merge groups build and smoke-test a local image without publishing. Formatting, Clippy, and tests run in the CI workflow. -Pushes to `main` and `v*` tags publish `ghcr.io/actix/github-release-router:sha-` candidates and run 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` without rebuilding the image. Successful `main` runs also update `:latest`; successful `v*` tag runs also publish the Git tag as an image tag. A failed check leaves the deployment tags unchanged. +Each push to `main` publishes a `ghcr.io/actix/github-release-router:sha-` 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` or a `v*` tag. +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. From 629caf1211b9bb780ae2fede975f5c8a185aa91d Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Fri, 9 Oct 2026 02:44:02 +0300 Subject: [PATCH 3/3] ci: remove merge queue support --- .github/workflows/build.yml | 4 +--- .github/workflows/ci.yml | 2 -- README.md | 4 ++-- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index a653aee..de5470f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,8 +2,6 @@ name: Build and publish container image on: pull_request: - merge_group: - types: [checks_requested] push: branches: - main @@ -18,7 +16,7 @@ concurrency: jobs: checks: - if: github.event_name != 'pull_request' && github.event_name != 'merge_group' + if: github.event_name != 'pull_request' uses: ./.github/workflows/ci.yml publish: diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3a9b04b..9868f6f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,8 +2,6 @@ name: CI on: pull_request: - merge_group: - types: [checks_requested] workflow_call: permissions: diff --git a/README.md b/README.md index 2b89241..e387a3e 100644 --- a/README.md +++ b/README.md @@ -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, test, and container build jobs on pull requests, merge groups, and pushes to `main`. You can also run the container workflow manually. +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 @@ -75,7 +75,7 @@ Run `just container-smoke` after `just container-build` to check non-root startu ## Container publishing -The [container workflow](.github/workflows/build.yml) builds the locked Dockerfile for `linux/amd64`. Pull requests and merge groups build and smoke-test a local image without publishing. Formatting, Clippy, and tests run in the CI workflow. +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. Each push to `main` publishes a `ghcr.io/actix/github-release-router:sha-` 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.