Skip to content

Commit 04d59bc

Browse files
Add CI status checks (#62)
1 parent 734ae5c commit 04d59bc

2 files changed

Lines changed: 112 additions & 0 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,56 @@ jobs:
238238
badge-title: ${{ matrix.scope }}
239239
path: "**/report/*.xml"
240240
reporter: java-junit
241+
242+
ci-pending:
243+
name: Set CI Pending
244+
runs-on: ubuntu-latest
245+
steps:
246+
- name: Set status check to pending
247+
env:
248+
GH_TOKEN: ${{ github.token }}
249+
run: |
250+
gh api \
251+
--method POST \
252+
-H "Accept: application/vnd.github+json" \
253+
-H "X-GitHub-Api-Version: 2022-11-28" \
254+
/repos/${{ github.repository }}/statuses/${{ github.sha }} \
255+
-f state=pending \
256+
-f target_url='${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
257+
-f description='Waiting for CI workflow to complete' \
258+
-f context='Mergeable Check'
259+
260+
ci-success:
261+
name: CI Success Check
262+
runs-on: ubuntu-latest
263+
needs: [ ci-pending, lint, bundle, build_and_test, helm-validate, helm-test, e2e-test ]
264+
if: always()
265+
steps:
266+
- name: Determine CI status
267+
id: status
268+
run: |
269+
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
270+
echo "state=failure" >> $GITHUB_OUTPUT
271+
echo "description=One or more CI jobs failed or were cancelled" >> $GITHUB_OUTPUT
272+
echo "One or more jobs failed or were cancelled"
273+
exit 1
274+
else
275+
echo "state=success" >> $GITHUB_OUTPUT
276+
echo "description=All CI jobs passed successfully" >> $GITHUB_OUTPUT
277+
echo "All required jobs passed successfully"
278+
fi
279+
280+
- name: Create commit status
281+
if: always()
282+
env:
283+
GH_TOKEN: ${{ github.token }}
284+
run: |
285+
gh api \
286+
--method POST \
287+
-H "Accept: application/vnd.github+json" \
288+
-H "X-GitHub-Api-Version: 2022-11-28" \
289+
/repos/${{ github.repository }}/statuses/${{ github.sha }} \
290+
-f state='${{ steps.status.outputs.state || 'error' }}' \
291+
-f target_url='${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
292+
-f description='${{ steps.status.outputs.description || 'CI workflow did not complete' }}' \
293+
-f context='Mergeable Check'

.github/workflows/docs-lint.yaml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8+
permissions:
9+
contents: read
10+
statuses: write
11+
checks: write
12+
pull-requests: write
813

914
jobs:
1015
vale:
@@ -15,6 +20,7 @@ jobs:
1520
- uses: errata-ai/vale-action@v2.1.1
1621
with:
1722
fail_on_error: 'true'
23+
1824
markdown-link-check:
1925
runs-on: ubuntu-latest
2026
steps:
@@ -23,3 +29,56 @@ jobs:
2329
with:
2430
config-file: ci/.markdown-link-check.json
2531
file-extension: '.md'
32+
33+
ci-pending:
34+
name: Set Documentation CI pending
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Set status check to pending
38+
env:
39+
GH_TOKEN: ${{ github.token }}
40+
run: |
41+
gh api \
42+
--method POST \
43+
-H "Accept: application/vnd.github+json" \
44+
-H "X-GitHub-Api-Version: 2022-11-28" \
45+
/repos/${{ github.repository }}/statuses/${{ github.sha }} \
46+
-f state=pending \
47+
-f target_url='${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
48+
-f description='Waiting for Docs CI workflow to complete' \
49+
-f context='Documentation Mergeable Check'
50+
51+
ci-success:
52+
name: Set CI Success Check
53+
runs-on: ubuntu-latest
54+
needs: [ ci-pending, vale, markdown-link-check ]
55+
if: always()
56+
steps:
57+
- name: Determine CI status
58+
id: status
59+
run: |
60+
if [[ "${{ contains(needs.*.result, 'failure') }}" == "true" || "${{ contains(needs.*.result, 'cancelled') }}" == "true" ]]; then
61+
echo "state=failure" >> $GITHUB_OUTPUT
62+
echo "description=One or more CI jobs failed or were cancelled" >> $GITHUB_OUTPUT
63+
echo "One or more jobs failed or were cancelled"
64+
exit 1
65+
else
66+
echo "state=success" >> $GITHUB_OUTPUT
67+
echo "description=All CI jobs passed successfully" >> $GITHUB_OUTPUT
68+
echo "All required jobs passed successfully"
69+
fi
70+
71+
- name: Create commit status
72+
if: always()
73+
env:
74+
GH_TOKEN: ${{ github.token }}
75+
run: |
76+
gh api \
77+
--method POST \
78+
-H "Accept: application/vnd.github+json" \
79+
-H "X-GitHub-Api-Version: 2022-11-28" \
80+
/repos/${{ github.repository }}/statuses/${{ github.sha }} \
81+
-f state='${{ steps.status.outputs.state || 'error' }}' \
82+
-f target_url='${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}' \
83+
-f description='${{ steps.status.outputs.description || 'Documentation CI workflow did not complete' }}' \
84+
-f context='Documentation Mergeable Check'

0 commit comments

Comments
 (0)