Skip to content

Commit 02f4531

Browse files
OttoAllmendingerllm-git
andcommitted
feat(ci): improve status check reporting with GitHub API
Update the status check workflow to use the GitHub API for setting commit statuses. This provides better visibility and more detailed status information in PRs while maintaining the clean "test / Test" status check name. Issue: BTC-2915 Co-authored-by: llm-git <llm-git@ttll.de>
1 parent b4ca64e commit 02f4531

1 file changed

Lines changed: 27 additions & 8 deletions

File tree

.github/workflows/status-check.yaml

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,42 @@
33
# avoiding the multi-level name composition that occurs with reusable workflows.
44
# Configure branch protection rules to require "test / Test" as the status check.
55

6-
name: "test / Test"
6+
name: "test"
77

88
on:
99
workflow_run:
1010
workflows: ["Build and Test"]
1111
types:
1212
- completed
1313

14+
permissions:
15+
statuses: write
16+
1417
jobs:
1518
status:
19+
name: "Test"
1620
runs-on: ubuntu-latest
1721
steps:
18-
- name: Check Build and Test Status
19-
run: |
20-
if [ "${{ github.event.workflow_run.conclusion }}" != "success" ]; then
21-
echo "Build and Test workflow failed"
22-
exit 1
23-
fi
24-
echo "Build and Test workflow succeeded"
22+
- name: Set commit status
23+
uses: actions/github-script@v7
24+
with:
25+
script: |
26+
const { owner, repo } = context.repo;
27+
const sha = context.payload.workflow_run.head_sha;
28+
const conclusion = context.payload.workflow_run.conclusion;
29+
const runUrl = context.payload.workflow_run.html_url;
30+
31+
const state = conclusion === 'success' ? 'success' :
32+
conclusion === 'failure' ? 'failure' :
33+
conclusion === 'cancelled' ? 'failure' : 'error';
34+
35+
await github.rest.repos.createCommitStatus({
36+
owner,
37+
repo,
38+
sha,
39+
state,
40+
target_url: runUrl,
41+
description: `Build and Test ${conclusion}`,
42+
context: 'test / Test'
43+
});
2544

0 commit comments

Comments
 (0)