Skip to content

Commit 648bf45

Browse files
committed
feat: add CI status check before release
- Add check-ci-status job that verifies all CI checks passed - Release workflow now fails if CI tests/lint/security checks failed - Prevents accidental releases of broken code
1 parent 6ea84fa commit 648bf45

1 file changed

Lines changed: 53 additions & 0 deletions

File tree

.github/workflows/release.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,61 @@ env:
2020
PYTHON_VERSION: "3.11"
2121

2222
jobs:
23+
check-ci-status:
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v4
27+
28+
- name: Get commit SHA
29+
id: get-sha
30+
run: |
31+
if [[ "${{ github.event_name }}" == "push" ]]; then
32+
echo "sha=${{ github.sha }}" >> $GITHUB_OUTPUT
33+
else
34+
# For workflow_dispatch, use the current HEAD
35+
echo "sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
36+
fi
37+
38+
- name: Check CI status
39+
uses: actions/github-script@v7
40+
with:
41+
script: |
42+
const sha = '${{ steps.get-sha.outputs.sha }}';
43+
console.log(`Checking CI status for commit: ${sha}`);
44+
45+
// Get check runs for this commit
46+
const { data: checkRuns } = await github.rest.checks.listForRef({
47+
owner: context.repo.owner,
48+
repo: context.repo.repo,
49+
ref: sha,
50+
});
51+
52+
// Find CI/CD workflow runs
53+
const ciRuns = checkRuns.check_runs.filter(run =>
54+
run.name.includes('test') || run.name.includes('lint') || run.name.includes('security')
55+
);
56+
57+
if (ciRuns.length === 0) {
58+
core.setFailed('No CI runs found for this commit. Please ensure CI has run successfully.');
59+
return;
60+
}
61+
62+
// Check if all CI runs passed
63+
const failedRuns = ciRuns.filter(run =>
64+
run.conclusion !== 'success' && run.conclusion !== 'skipped'
65+
);
66+
67+
if (failedRuns.length > 0) {
68+
const failedNames = failedRuns.map(run => `${run.name}: ${run.conclusion}`).join(', ');
69+
core.setFailed(`CI checks failed: ${failedNames}`);
70+
return;
71+
}
72+
73+
console.log('All CI checks passed!');
74+
2375
validate-version:
2476
runs-on: ubuntu-latest
77+
needs: check-ci-status
2578
outputs:
2679
version: ${{ steps.version.outputs.version }}
2780
tag_name: ${{ steps.version.outputs.tag_name }}

0 commit comments

Comments
 (0)