From 0a830174e99e0d25df89aa26fbd7db9314c1074d Mon Sep 17 00:00:00 2001 From: sjmiller609 <7516283+sjmiller609@users.noreply.github.com> Date: Sat, 7 Nov 2026 16:05:31 +0000 Subject: [PATCH 1/7] Read Docker Hub credentials from SSM --- .github/workflows/test.yml | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d5779d744..08b683b3f 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,6 +37,7 @@ env: permissions: contents: read + id-token: write jobs: test: @@ -168,11 +169,17 @@ jobs: # Slash-command runs are maintainer-approved and need authenticated pulls # for images that are not covered by the prewarm cache. + - name: Read Docker Hub credentials from SSM + id: dockerhub + uses: kernel/kernel-images/.github/actions/dockerhub-credentials@9bda8b5f248d2e020cec3503c3bcc78a188ea2b3 + with: + role-arn: arn:aws:iam::613957054632:role/github-actions-kernel-images + - name: Login to Docker Hub uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} + username: ${{ steps.dockerhub.outputs.username }} + password: ${{ steps.dockerhub.outputs.password }} - name: Generate OpenAPI code run: make oapi-generate @@ -364,11 +371,20 @@ jobs: done docker info + - name: Install AWS CLI + run: command -v aws >/dev/null || brew install awscli + + - name: Read Docker Hub credentials from SSM + id: dockerhub + uses: kernel/kernel-images/.github/actions/dockerhub-credentials@9bda8b5f248d2e020cec3503c3bcc78a188ea2b3 + with: + role-arn: arn:aws:iam::613957054632:role/github-actions-kernel-images + - name: Login to Docker Hub uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} + username: ${{ steps.dockerhub.outputs.username }} + password: ${{ steps.dockerhub.outputs.password }} - name: Install dependencies run: | brew list e2fsprogs &>/dev/null || brew install e2fsprogs @@ -469,11 +485,20 @@ jobs: # Self-hosted runners retain Docker layers across jobs. Prune only # what is stale, and fall back to a full prune when host disk is low. bash scripts/docker-ci-cleanup.sh + - name: Install AWS CLI + run: command -v aws >/dev/null || brew install awscli + + - name: Read Docker Hub credentials from SSM + id: dockerhub + uses: kernel/kernel-images/.github/actions/dockerhub-credentials@9bda8b5f248d2e020cec3503c3bcc78a188ea2b3 + with: + role-arn: arn:aws:iam::613957054632:role/github-actions-kernel-images + - name: Login to Docker Hub uses: docker/login-action@v3 with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} + username: ${{ steps.dockerhub.outputs.username }} + password: ${{ steps.dockerhub.outputs.password }} - name: Build E2E install artifacts env: GITHUB_TOKEN: ${{ github.token }} From d961f89d3bbab257b71ba525414141b784f02075 Mon Sep 17 00:00:00 2001 From: sjmiller609 <7516283+sjmiller609@users.noreply.github.com> Date: Sat, 7 Nov 2026 16:23:13 +0000 Subject: [PATCH 2/7] Pin the shared credential action --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 08b683b3f..a9e70bae7 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -171,7 +171,7 @@ jobs: # for images that are not covered by the prewarm cache. - name: Read Docker Hub credentials from SSM id: dockerhub - uses: kernel/kernel-images/.github/actions/dockerhub-credentials@9bda8b5f248d2e020cec3503c3bcc78a188ea2b3 + uses: kernel/kernel-images/.github/actions/dockerhub-credentials@00132e625d389a25deaa4973abd1ba179f70219f with: role-arn: arn:aws:iam::613957054632:role/github-actions-kernel-images @@ -376,7 +376,7 @@ jobs: - name: Read Docker Hub credentials from SSM id: dockerhub - uses: kernel/kernel-images/.github/actions/dockerhub-credentials@9bda8b5f248d2e020cec3503c3bcc78a188ea2b3 + uses: kernel/kernel-images/.github/actions/dockerhub-credentials@00132e625d389a25deaa4973abd1ba179f70219f with: role-arn: arn:aws:iam::613957054632:role/github-actions-kernel-images @@ -490,7 +490,7 @@ jobs: - name: Read Docker Hub credentials from SSM id: dockerhub - uses: kernel/kernel-images/.github/actions/dockerhub-credentials@9bda8b5f248d2e020cec3503c3bcc78a188ea2b3 + uses: kernel/kernel-images/.github/actions/dockerhub-credentials@00132e625d389a25deaa4973abd1ba179f70219f with: role-arn: arn:aws:iam::613957054632:role/github-actions-kernel-images From 649cc1c7346607e5d73ad93564320a0bb3ddcda0 Mon Sep 17 00:00:00 2001 From: sjmiller609 <7516283+sjmiller609@users.noreply.github.com> Date: Mon, 9 Nov 2026 16:05:13 +0000 Subject: [PATCH 3/7] Pin the credential reader role-chaining fix --- .github/workflows/test.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a9e70bae7..eabd98cb5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -171,7 +171,7 @@ jobs: # for images that are not covered by the prewarm cache. - name: Read Docker Hub credentials from SSM id: dockerhub - uses: kernel/kernel-images/.github/actions/dockerhub-credentials@00132e625d389a25deaa4973abd1ba179f70219f + uses: kernel/kernel-images/.github/actions/dockerhub-credentials@230a3816ef28b47af3c8ab3490064f2620735f2c with: role-arn: arn:aws:iam::613957054632:role/github-actions-kernel-images @@ -376,7 +376,7 @@ jobs: - name: Read Docker Hub credentials from SSM id: dockerhub - uses: kernel/kernel-images/.github/actions/dockerhub-credentials@00132e625d389a25deaa4973abd1ba179f70219f + uses: kernel/kernel-images/.github/actions/dockerhub-credentials@230a3816ef28b47af3c8ab3490064f2620735f2c with: role-arn: arn:aws:iam::613957054632:role/github-actions-kernel-images @@ -490,7 +490,7 @@ jobs: - name: Read Docker Hub credentials from SSM id: dockerhub - uses: kernel/kernel-images/.github/actions/dockerhub-credentials@00132e625d389a25deaa4973abd1ba179f70219f + uses: kernel/kernel-images/.github/actions/dockerhub-credentials@230a3816ef28b47af3c8ab3490064f2620735f2c with: role-arn: arn:aws:iam::613957054632:role/github-actions-kernel-images From 475235487de4908a7a3e80be18361bc9903a133a Mon Sep 17 00:00:00 2001 From: sjmiller609 <7516283+sjmiller609@users.noreply.github.com> Date: Wed, 11 Nov 2026 16:20:24 +0000 Subject: [PATCH 4/7] Use Docker Hub OIDC for test pulls --- .github/workflows/test.yml | 51 +++++++++++--------------------------- 1 file changed, 15 insertions(+), 36 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index eabd98cb5..a29353e48 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -169,17 +169,12 @@ jobs: # Slash-command runs are maintainer-approved and need authenticated pulls # for images that are not covered by the prewarm cache. - - name: Read Docker Hub credentials from SSM - id: dockerhub - uses: kernel/kernel-images/.github/actions/dockerhub-credentials@230a3816ef28b47af3c8ab3490064f2620735f2c + - name: Login to Docker Hub with OIDC + uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0 with: - role-arn: arn:aws:iam::613957054632:role/github-actions-kernel-images - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ steps.dockerhub.outputs.username }} - password: ${{ steps.dockerhub.outputs.password }} + username: onkernel + env: + DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_PULL_CONNECTION_ID }} - name: Generate OpenAPI code run: make oapi-generate @@ -371,20 +366,12 @@ jobs: done docker info - - name: Install AWS CLI - run: command -v aws >/dev/null || brew install awscli - - - name: Read Docker Hub credentials from SSM - id: dockerhub - uses: kernel/kernel-images/.github/actions/dockerhub-credentials@230a3816ef28b47af3c8ab3490064f2620735f2c - with: - role-arn: arn:aws:iam::613957054632:role/github-actions-kernel-images - - - name: Login to Docker Hub - uses: docker/login-action@v3 + - name: Login to Docker Hub with OIDC + uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0 with: - username: ${{ steps.dockerhub.outputs.username }} - password: ${{ steps.dockerhub.outputs.password }} + username: onkernel + env: + DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_PULL_CONNECTION_ID }} - name: Install dependencies run: | brew list e2fsprogs &>/dev/null || brew install e2fsprogs @@ -485,20 +472,12 @@ jobs: # Self-hosted runners retain Docker layers across jobs. Prune only # what is stale, and fall back to a full prune when host disk is low. bash scripts/docker-ci-cleanup.sh - - name: Install AWS CLI - run: command -v aws >/dev/null || brew install awscli - - - name: Read Docker Hub credentials from SSM - id: dockerhub - uses: kernel/kernel-images/.github/actions/dockerhub-credentials@230a3816ef28b47af3c8ab3490064f2620735f2c + - name: Login to Docker Hub with OIDC + uses: docker/login-action@81c6f93d4bc991e510b342a00b419b3bb4efc5c6 # v4.7.0 with: - role-arn: arn:aws:iam::613957054632:role/github-actions-kernel-images - - - name: Login to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ steps.dockerhub.outputs.username }} - password: ${{ steps.dockerhub.outputs.password }} + username: onkernel + env: + DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_PULL_CONNECTION_ID }} - name: Build E2E install artifacts env: GITHUB_TOKEN: ${{ github.token }} From c47f3d2ab6173823c560ed819fa05c2b85286a1d Mon Sep 17 00:00:00 2001 From: sjmiller609 <7516283+sjmiller609@users.noreply.github.com> Date: Mon, 23 Nov 2026 20:25:42 +0000 Subject: [PATCH 5/7] Limit authenticated Hypeman CI to repository branches --- .github/workflows/test-command.yml | 30 +++++++------------ .github/workflows/test.yml | 46 ++++++++++++++---------------- 2 files changed, 32 insertions(+), 44 deletions(-) diff --git a/.github/workflows/test-command.yml b/.github/workflows/test-command.yml index fb2802da6..ffe3fd87e 100644 --- a/.github/workflows/test-command.yml +++ b/.github/workflows/test-command.yml @@ -56,15 +56,21 @@ jobs: run: | set -euo pipefail gh api "repos/$REPO/pulls/$PR_NUMBER" \ - --jq '[.state, .base.ref, .head.repo.full_name, .head.sha] | @tsv' > "$RUNNER_TEMP/pr.tsv" - read -r state base_repo head_repo head_sha < "$RUNNER_TEMP/pr.tsv" + --jq '[.state, .base.ref, .head.repo.full_name, .head.sha, .head.ref] | @tsv' > "$RUNNER_TEMP/pr.tsv" + read -r state base_repo head_repo head_sha head_ref < "$RUNNER_TEMP/pr.tsv" if [ "$state" != "open" ] || [ "$base_repo" != "main" ] || [ -z "$head_repo" ]; then echo "::error::only open pull requests targeting main can be tested" exit 1 fi + if [ "$head_repo" != "$REPO" ]; then + gh api "repos/$REPO/issues/$PR_NUMBER/comments" \ + --field body="Full CI runs from branches in this repository only. A maintainer can review the changes and push them to a branch here to run CI." + exit 1 + fi { echo "head_repo=$head_repo" echo "head_sha=$head_sha" + echo "head_ref=$head_ref" } >> "$GITHUB_OUTPUT" - name: Reject commits pushed after the command @@ -93,23 +99,6 @@ jobs: exit 1 fi - - name: Reject dependency changes - if: steps.command.outputs.run == 'true' && steps.pr.outputs.head_repo != github.repository - env: - GH_TOKEN: ${{ github.token }} - REPO: ${{ github.repository }} - PR_NUMBER: ${{ github.event.issue.number }} - run: | - set -euo pipefail - dependency_files="$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/files" \ - --jq '.[] | select(.filename == "go.mod" or .filename == "go.sum") | .filename')" - if [ -n "$dependency_files" ]; then - gh api "repos/$REPO/issues/$PR_NUMBER/comments" \ - --field body="Tests were not dispatched because public contributions cannot change go.mod or go.sum." - echo "::error::public contribution changes dependency files: $dependency_files" - exit 1 - fi - - name: Dispatch tests if: steps.command.outputs.run == 'true' env: @@ -118,6 +107,7 @@ jobs: PR_NUMBER: ${{ github.event.issue.number }} HEAD_REPO: ${{ steps.pr.outputs.head_repo }} HEAD_SHA: ${{ steps.pr.outputs.head_sha }} + HEAD_REF: ${{ steps.pr.outputs.head_ref }} run: | set -euo pipefail current_head_sha="$(gh api "repos/$REPO/pulls/$PR_NUMBER" --jq '.head.sha')" @@ -130,7 +120,7 @@ jobs: gh workflow run test.yml \ --repo "$REPO" \ - --ref main \ + --ref "$HEAD_REF" \ --field pr_head_repo="$HEAD_REPO" \ --field pr_head_sha="$HEAD_SHA" \ --field pr_number="$PR_NUMBER" diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 5197e6fc0..0ad585c1d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -5,7 +5,7 @@ on: workflow_dispatch: inputs: pr_head_repo: - description: "Fork repository containing the PR commit" + description: "Repository containing the PR branch (must be this repository)" required: false type: string pr_head_sha: @@ -28,26 +28,25 @@ concurrency: group: test-${{ (github.event_name == 'push' && github.ref != 'refs/heads/main') && github.ref || github.run_id }} cancel-in-progress: ${{ github.event_name == 'push' && github.ref != 'refs/heads/main' }} -# A slash-command dispatch supplies a fork repository and immutable commit SHA. -# Normal push runs use the upstream repository and pushed ref. -env: - TEST_PR_HEAD_REPO: ${{ inputs.pr_head_repo || github.repository }} - TEST_SOURCE_REPO: ${{ inputs.pr_head_repo || github.repository }} - TEST_SOURCE_REF: ${{ inputs.pr_head_sha || github.ref }} - permissions: contents: read - id-token: write + +env: + DOCKERHUB_OIDC_CONNECTIONID: e87832ce-a4e3-4386-8b17-44a6085109f2 + DOCKERHUB_OIDC_EXPIREIN: '3600' jobs: test: + # Test the commit selected by GitHub, not a dispatch-supplied checkout. + if: ${{ github.repository == 'kernel/hypeman' && (!inputs.pr_head_repo || inputs.pr_head_repo == github.repository) && (!inputs.pr_head_sha || inputs.pr_head_sha == github.sha) }} runs-on: [self-hosted, linux, x64, kvm] + permissions: + contents: read + id-token: write steps: - uses: actions/checkout@v4.4.0 with: clean: false - repository: ${{ env.TEST_SOURCE_REPO }} - ref: ${{ env.TEST_SOURCE_REF }} persist-credentials: false - name: Clean workspace (preserve binary caches) @@ -167,14 +166,13 @@ jobs: done exit 1 - # Slash-command runs are maintainer-approved and need authenticated pulls - # for images that are not covered by the prewarm cache. + - name: Create isolated Docker config + run: echo "DOCKER_CONFIG=$(mktemp -d "$RUNNER_TEMP/docker-config.XXXXXX")" >> "$GITHUB_ENV" + - name: Login to Docker Hub with OIDC uses: docker/login-action@v4.7.0 with: username: onkernel - env: - DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_PULL_CONNECTION_ID }} - name: Generate OpenAPI code run: make oapi-generate @@ -222,7 +220,6 @@ jobs: - name: Prewarm test cache env: - DOCKER_CONFIG: /home/debianuser/.docker GITHUB_TOKEN: ${{ github.token }} HYPEMAN_TEST_REGISTRY: 127.0.0.1:5001 run: | @@ -262,13 +259,11 @@ jobs: env: GO_TEST_TIMEOUT: 600s GITHUB_TOKEN: ${{ github.token }} - # Docker auth for tests running as root (sudo) - DOCKER_CONFIG: /home/debianuser/.docker # TLS/ACME testing (optional - tests will skip if not configured) - ACME_EMAIL: ${{ env.TEST_PR_HEAD_REPO == github.repository && secrets.ACME_EMAIL || '' }} + ACME_EMAIL: ${{ secrets.ACME_EMAIL }} ACME_DNS_PROVIDER: "cloudflare" ACME_CA: "https://acme-staging-v02.api.letsencrypt.org/directory" - CLOUDFLARE_API_TOKEN: ${{ env.TEST_PR_HEAD_REPO == github.repository && secrets.CLOUDFLARE_API_TOKEN || '' }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} TLS_TEST_DOMAIN: "test.hypeman-development.com" TLS_ALLOWED_DOMAINS: '*.hypeman-development.com' HYPEMAN_TEST_PREWARM_STRICT: "1" @@ -325,7 +320,11 @@ jobs: --field target_url="$GITHUB_SERVER_URL/$REPO/actions/runs/$GITHUB_RUN_ID" test-darwin: + if: ${{ github.repository == 'kernel/hypeman' && (!inputs.pr_head_repo || inputs.pr_head_repo == github.repository) && (!inputs.pr_head_sha || inputs.pr_head_sha == github.sha) }} runs-on: [self-hosted, macos, arm64] + permissions: + contents: read + id-token: write concurrency: group: macos-ci-test-${{ inputs.pr_head_sha || github.ref }} cancel-in-progress: true @@ -374,8 +373,6 @@ jobs: uses: docker/login-action@v4.7.0 with: username: onkernel - env: - DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_PULL_CONNECTION_ID }} - name: Install dependencies run: | brew list e2fsprogs &>/dev/null || brew install e2fsprogs @@ -443,6 +440,9 @@ jobs: e2e-install: runs-on: [self-hosted, macos, arm64] needs: test-darwin + permissions: + contents: read + id-token: write concurrency: group: macos-ci-e2e-${{ inputs.pr_head_sha || github.ref }} cancel-in-progress: true @@ -480,8 +480,6 @@ jobs: uses: docker/login-action@v4.7.0 with: username: onkernel - env: - DOCKERHUB_OIDC_CONNECTIONID: ${{ vars.DOCKERHUB_OIDC_PULL_CONNECTION_ID }} - name: Build E2E install artifacts env: GITHUB_TOKEN: ${{ github.token }} From 6d3c62ca7f9964f4ca3010e8da6b29805c0aeca8 Mon Sep 17 00:00:00 2001 From: sjmiller609 <7516283+sjmiller609@users.noreply.github.com> Date: Mon, 23 Nov 2026 20:38:02 +0000 Subject: [PATCH 6/7] Do not publish status for skipped Hypeman tests --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0ad585c1d..f71fdaa5b 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -280,7 +280,7 @@ jobs: make test TEST_TIMEOUT=20m report-pr-test: - if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }} + if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.pr_number != '' && (needs.test.result == 'success' || needs.test.result == 'failure') }} needs: test runs-on: ubuntu-latest permissions: From f3e1191862951101b236e2c4793a09a068954326 Mon Sep 17 00:00:00 2001 From: sjmiller609 <7516283+sjmiller609@users.noreply.github.com> Date: Mon, 23 Nov 2026 21:00:04 +0000 Subject: [PATCH 7/7] Remove stale macOS checkout inputs --- .github/workflows/test.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f71fdaa5b..4c309f938 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -333,8 +333,6 @@ jobs: steps: - uses: actions/checkout@v4.4.0 with: - repository: ${{ env.TEST_SOURCE_REPO }} - ref: ${{ env.TEST_SOURCE_REF }} persist-credentials: false - uses: actions/setup-go@v6.5.0 with: @@ -449,8 +447,6 @@ jobs: steps: - uses: actions/checkout@v4.4.0 with: - repository: ${{ env.TEST_SOURCE_REPO }} - ref: ${{ env.TEST_SOURCE_REF }} persist-credentials: false - uses: actions/setup-go@v6.5.0 with: