Skip to content

Commit 8ef7309

Browse files
committed
Add gateway pattern for CI required checks
The push_javascript workflow pushes rebuilt JS bundles to PR branches after CI passes. It used [skip ci] to avoid retriggering the full CI suite, but this prevented required status checks from being reported on the new commit SHA, making PRs unmergeable. Each workflow now has a check_bot_commit job that detects commits from the CI bot (alchemy@blish.cloud) and a gateway job that becomes the single required check. Expensive jobs are skipped for bot commits but the gateway always runs and reports a status, so PRs remain mergeable.
1 parent 33f0394 commit 8ef7309

5 files changed

Lines changed: 102 additions & 5 deletions

File tree

.github/workflows/brakeman-analysis.yml

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ on:
2121
- cron: "40 4 * * 2"
2222

2323
jobs:
24+
check_bot_commit:
25+
uses: ./.github/workflows/check-bot-commit.yml
26+
2427
brakeman-scan:
28+
needs: [check_bot_commit]
29+
if: needs.check_bot_commit.outputs.is_bot != 'true'
2530
name: Brakeman Scan
2631
runs-on: ubuntu-24.04
2732
steps:
@@ -47,3 +52,18 @@ jobs:
4752
if: always()
4853
with:
4954
sarif_file: output.sarif.json
55+
56+
brakeman-success:
57+
name: "Brakeman Success"
58+
if: always()
59+
needs: [check_bot_commit, brakeman-scan]
60+
runs-on: ubuntu-latest
61+
permissions:
62+
contents: read
63+
steps:
64+
- name: Check results
65+
run: |
66+
if [[ "${{ needs.brakeman-scan.result }}" != "success" && "${{ needs.brakeman-scan.result }}" != "skipped" ]]; then
67+
echo "Failed: ${{ needs.brakeman-scan.result }}"
68+
exit 1
69+
fi

.github/workflows/build_test.yml

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ on:
1717
pull_request:
1818

1919
jobs:
20+
check_bot_commit:
21+
uses: ./.github/workflows/check-bot-commit.yml
22+
2023
check_package_json:
2124
permissions:
2225
contents: read
@@ -78,8 +81,11 @@ jobs:
7881
RSpec:
7982
permissions:
8083
contents: read
81-
needs: [check_package_json, build_javascript]
82-
if: ${{ always() && (needs.build_javascript.result == 'success' || needs.build_javascript.result == 'skipped') }}
84+
needs: [check_package_json, build_javascript, check_bot_commit]
85+
if: >
86+
always() &&
87+
needs.check_bot_commit.outputs.is_bot != 'true' &&
88+
(needs.build_javascript.result == 'success' || needs.build_javascript.result == 'skipped')
8389
runs-on: ubuntu-24.04
8490
strategy:
8591
fail-fast: false
@@ -223,8 +229,11 @@ jobs:
223229
permissions:
224230
contents: read
225231
runs-on: ubuntu-24.04
226-
needs: [check_package_json, build_javascript]
227-
if: ${{ always() && (needs.build_javascript.result == 'success' || needs.build_javascript.result == 'skipped') }}
232+
needs: [check_package_json, build_javascript, check_bot_commit]
233+
if: >
234+
always() &&
235+
needs.check_bot_commit.outputs.is_bot != 'true' &&
236+
(needs.build_javascript.result == 'success' || needs.build_javascript.result == 'skipped')
228237
env:
229238
NODE_ENV: test
230239
steps:
@@ -246,3 +255,20 @@ jobs:
246255
run: bun install
247256
- name: Run vitest
248257
run: bun run test
258+
259+
build-test-success:
260+
name: "Build & Test Success"
261+
if: always()
262+
needs: [check_bot_commit, RSpec, Vitest]
263+
runs-on: ubuntu-latest
264+
permissions:
265+
contents: read
266+
steps:
267+
- name: Check results
268+
run: |
269+
for result in "${{ needs.RSpec.result }}" "${{ needs.Vitest.result }}"; do
270+
if [[ "$result" != "success" && "$result" != "skipped" ]]; then
271+
echo "Failed: $result"
272+
exit 1
273+
fi
274+
done
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: Check Bot Commit
2+
3+
on:
4+
workflow_call:
5+
outputs:
6+
is_bot:
7+
value: ${{ jobs.check.outputs.is_bot }}
8+
9+
jobs:
10+
check:
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
outputs:
15+
is_bot: ${{ steps.check.outputs.is_bot }}
16+
steps:
17+
- id: check
18+
env:
19+
GH_TOKEN: ${{ github.token }}
20+
run: |
21+
SHA="${{ github.event.pull_request.head.sha || github.sha }}"
22+
AUTHOR_EMAIL=$(gh api "repos/${{ github.repository }}/commits/${SHA}" --jq '.commit.author.email')
23+
if [ "$AUTHOR_EMAIL" = "alchemy@blish.cloud" ]; then
24+
echo "is_bot=true" >> $GITHUB_OUTPUT
25+
fi

.github/workflows/lint.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ permissions:
1010
contents: read
1111

1212
jobs:
13+
check_bot_commit:
14+
uses: ./.github/workflows/check-bot-commit.yml
15+
1316
Standard:
17+
needs: [check_bot_commit]
18+
if: needs.check_bot_commit.outputs.is_bot != 'true'
1419
runs-on: ubuntu-24.04
1520
steps:
1621
- name: Checkout code
@@ -24,6 +29,8 @@ jobs:
2429
- name: Lint Ruby files
2530
run: bundle exec standardrb
2631
ESLint:
32+
needs: [check_bot_commit]
33+
if: needs.check_bot_commit.outputs.is_bot != 'true'
2734
runs-on: ubuntu-24.04
2835
steps:
2936
- name: Checkout
@@ -42,6 +49,8 @@ jobs:
4249
- name: Lint code
4350
run: bun run --bun eslint
4451
Prettier:
52+
needs: [check_bot_commit]
53+
if: needs.check_bot_commit.outputs.is_bot != 'true'
4554
runs-on: ubuntu-24.04
4655
steps:
4756
- name: Checkout
@@ -60,6 +69,8 @@ jobs:
6069
- name: Lint code
6170
run: bun run --bun lint
6271
Herb:
72+
needs: [check_bot_commit]
73+
if: needs.check_bot_commit.outputs.is_bot != 'true'
6374
runs-on: ubuntu-24.04
6475
steps:
6576
- name: Checkout
@@ -77,3 +88,18 @@ jobs:
7788
run: bun install
7889
- name: Lint erb files
7990
run: bun run --bun herb-lint
91+
92+
lint-success:
93+
name: "Lint Success"
94+
if: always()
95+
needs: [check_bot_commit, Standard, ESLint, Prettier, Herb]
96+
runs-on: ubuntu-latest
97+
steps:
98+
- name: Check results
99+
run: |
100+
for result in "${{ needs.Standard.result }}" "${{ needs.ESLint.result }}" "${{ needs.Prettier.result }}" "${{ needs.Herb.result }}"; do
101+
if [[ "$result" != "success" && "$result" != "skipped" ]]; then
102+
echo "Failed: $result"
103+
exit 1
104+
fi
105+
done

.github/workflows/push_javascript.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
git config --local user.name 'AlchemyCMS - CI Bot'
5454
git config --local user.email 'alchemy@blish.cloud'
5555
git add vendor/javascript bun.lock
56-
git commit -m "Update JS packages" -m "Rebuilt packages after updating dependencies." -m "[skip ci]"
56+
git commit -m "Update JS packages" -m "Rebuilt packages after updating dependencies."
5757
- name: Push changes
5858
if: steps.git-status.outputs.changed == 'true'
5959
uses: ad-m/github-push-action@master

0 commit comments

Comments
 (0)