Skip to content

Commit cc44aaa

Browse files
committed
feat: trigger CI after auto-format workflow completes
Add workflow_run trigger to CI so it runs after the Auto Format workflow completes. This ensures CI validates code after auto-formatting commits changes, preventing PRs from being in a limbo state.
1 parent 90a171e commit cc44aaa

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

.github/workflows/ci.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ on:
44
push:
55
branches: [ main, 'release-please--branches--main' ]
66
pull_request:
7+
workflow_run:
8+
workflows: ["Auto Format"]
9+
types:
10+
- completed
711

812
env:
913
REGISTRY: ghcr.io
@@ -13,12 +17,15 @@ jobs:
1317
test:
1418
name: Test
1519
runs-on: ubuntu-latest
20+
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
1621

1722
steps:
1823
- name: Checkout code
1924
uses: actions/checkout@v5
2025
with:
2126
fetch-depth: 0
27+
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
28+
sha: ${{ github.event.workflow_run.head_sha || github.sha }}
2229

2330
- name: Set up Go 1.25
2431
uses: actions/setup-go@v6
@@ -41,12 +48,15 @@ jobs:
4148
lint:
4249
name: Lint
4350
runs-on: ubuntu-latest
51+
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
4452

4553
steps:
4654
- name: Checkout code
4755
uses: actions/checkout@v5
4856
with:
4957
fetch-depth: 0
58+
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
59+
sha: ${{ github.event.workflow_run.head_sha || github.sha }}
5060

5161
- name: Run linting using Makefile
5262
run: make lint-only
@@ -55,12 +65,15 @@ jobs:
5565
name: Build
5666
runs-on: ubuntu-latest
5767
needs: [test]
68+
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
5869

5970
steps:
6071
- name: Checkout code
6172
uses: actions/checkout@v5
6273
with:
6374
fetch-depth: 0
75+
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
76+
sha: ${{ github.event.workflow_run.head_sha || github.sha }}
6477

6578
- name: Set up Go
6679
uses: actions/setup-go@v6
@@ -81,6 +94,7 @@ jobs:
8194
security:
8295
name: Security Scan
8396
runs-on: ubuntu-latest
97+
if: ${{ github.event_name != 'workflow_run' || github.event.workflow_run.conclusion == 'success' }}
8498
permissions:
8599
contents: read
86100
security-events: write
@@ -90,6 +104,8 @@ jobs:
90104
uses: actions/checkout@v5
91105
with:
92106
fetch-depth: 0
107+
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
108+
sha: ${{ github.event.workflow_run.head_sha || github.sha }}
93109

94110
- name: Run Trivy vulnerability scanner
95111
uses: aquasecurity/trivy-action@master
@@ -104,7 +120,7 @@ jobs:
104120
name: Development Build
105121
runs-on: ubuntu-latest
106122
needs: [test]
107-
if: github.event_name == 'push'
123+
if: github.event_name == 'push' || (github.event_name == 'workflow_run' && github.event.workflow_run.conclusion == 'success')
108124
permissions:
109125
contents: read
110126
packages: write
@@ -114,6 +130,8 @@ jobs:
114130
uses: actions/checkout@v5
115131
with:
116132
fetch-depth: 0
133+
ref: ${{ github.event.workflow_run.head_branch || github.ref }}
134+
sha: ${{ github.event.workflow_run.head_sha || github.sha }}
117135

118136
- name: Set up Docker Buildx
119137
uses: docker/setup-buildx-action@v3

0 commit comments

Comments
 (0)