File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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 " $@ "
Original file line number Diff line number Diff line change 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
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 }}"
Original file line number Diff line number Diff line change 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 :
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 }}"
Original file line number Diff line number Diff line change 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
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 }}"
You can’t perform that action at this time.
0 commit comments