Skip to content

Commit 5c9e694

Browse files
indradhanushclaude
andcommitted
ci: report commit status for workflow_run-triggered checks
build-push-agent-bundle.yml, build-push-controller-manager.yml, and e2e.yml now trigger via workflow_run instead of directly on pull_request, which means their runs don't automatically surface as a check on the PR that triggered the upstream workflow - the same gap already solved the same way in kaapi's helm-upgrade.yml. Each now posts a pending commit status against the original commit as soon as it starts, and a success/failure status when it finishes, via a shared .ci/report-commit-status.sh script instead of inlining the same gh api call three times. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
1 parent 705e49b commit 5c9e694

4 files changed

Lines changed: 67 additions & 0 deletions

File tree

.ci/report-commit-status.sh

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env bash
2+
set -Eeuo pipefail
3+
4+
# report-commit-status.sh - posts a commit status against a given SHA via the GitHub API.
5+
#
6+
# workflow_run-triggered jobs don't automatically surface as a check on the PR that triggered
7+
# the upstream workflow, so downstream workflows call this explicitly (once as "pending" when
8+
# they start, once as "success"/"failure" when they finish) to report their own status back
9+
# onto that commit.
10+
#
11+
# Usage: report-commit-status.sh <state> <context> <description>
12+
# Required env: GH_TOKEN, SHA (the commit to report against)
13+
# Relies on GitHub Actions' own GITHUB_REPOSITORY, GITHUB_SERVER_URL, GITHUB_RUN_ID.
14+
15+
main() {
16+
local state=$1
17+
local context=$2
18+
local description=$3
19+
20+
gh api "repos/${GITHUB_REPOSITORY}/statuses/${SHA}" \
21+
--method POST \
22+
-f state="${state}" \
23+
-f context="${context}" \
24+
-f description="${description}" \
25+
-f target_url="${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
26+
}
27+
28+
main "$@"

.github/workflows/build-push-agent-bundle.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ jobs:
1717
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
1818
fetch-depth: 0
1919

20+
- name: Report pending commit status
21+
env:
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
24+
run: bash .ci/report-commit-status.sh pending build-push-agent-bundle "Agent bundle build in progress"
25+
2026
- name: Download agent binary artifact
2127
if: ${{ github.event_name == 'workflow_run' }}
2228
uses: actions/download-artifact@v4
@@ -46,3 +52,10 @@ jobs:
4652
env:
4753
SKIP_BUILD: ${{ github.event_name == 'workflow_run' && '1' || '' }}
4854
run: bash .ci/build-push-agent-deb.sh
55+
56+
- name: Report final commit status
57+
if: always()
58+
env:
59+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
60+
SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
61+
run: bash .ci/report-commit-status.sh "${{ job.status == 'success' && 'success' || 'failure' }}" build-push-agent-bundle "Agent bundle build ${{ job.status }}"

.github/workflows/build-push-controller-manager.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ jobs:
1717
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
1818
fetch-depth: 0
1919

20+
- name: Report pending commit status
21+
env:
22+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
23+
SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
24+
run: bash .ci/report-commit-status.sh pending build-push-controller-manager "Controller manager build in progress"
25+
2026
- name: Set up Go
2127
uses: actions/setup-go@v4
2228
with:
@@ -48,3 +54,10 @@ jobs:
4854
name: controller-manager-image
4955
path: controller-manager-image.tar
5056
retention-days: 1
57+
58+
- name: Report final commit status
59+
if: always()
60+
env:
61+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
62+
SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
63+
run: bash .ci/report-commit-status.sh "${{ job.status == 'success' && 'success' || 'failure' }}" build-push-controller-manager "Controller manager build ${{ job.status }}"

.github/workflows/e2e.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ jobs:
1818
with:
1919
ref: ${{ github.event.workflow_run.head_sha || github.sha }}
2020

21+
- name: Report pending commit status
22+
env:
23+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24+
SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
25+
run: bash .ci/report-commit-status.sh pending e2e-suite "e2e tests in progress"
26+
2127
- name: Download controller manager image artifact
2228
if: ${{ github.event_name == 'workflow_run' }}
2329
uses: actions/download-artifact@v4
@@ -51,3 +57,10 @@ jobs:
5157
env:
5258
SKIP_BUILD: ${{ github.event_name == 'workflow_run' && '1' || '' }}
5359
run: yes | GINKGO_NODES=7 make test-e2e
60+
61+
- name: Report final commit status
62+
if: always()
63+
env:
64+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
65+
SHA: ${{ github.event.workflow_run.head_sha || github.sha }}
66+
run: bash .ci/report-commit-status.sh "${{ job.status == 'success' && 'success' || 'failure' }}" e2e-suite "e2e tests ${{ job.status }}"

0 commit comments

Comments
 (0)