Skip to content

Commit 7761f2c

Browse files
committed
fix(template): Use new detect-changes action so the workflow can pass the required job check
1 parent e034deb commit 7761f2c

File tree

1 file changed

+45
-14
lines changed

1 file changed

+45
-14
lines changed

template/.github/workflows/build.yaml.j2

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,7 @@ on:
1818
# Run every Saturday morning: https://crontab.guru/#15_3_*_*_6
1919
- cron: '15 3 * * 6'
2020
pull_request:
21-
paths:
22-
- '.github/workflows/build.yaml'
23-
- 'rust-toolchain.toml'
24-
- '.dockerignore'
25-
- 'deploy/**'
26-
- '.cargo/**'
27-
- 'docker/**'
28-
- 'Cargo.*'
29-
- '*.rs'
21+
# Do not limit by paths. This workflow contains a required job.
3022
merge_group:
3123

3224
env:
@@ -39,8 +31,42 @@ env:
3931
CARGO_TERM_COLOR: always
4032

4133
jobs:
34+
# This workflow contains a "required job", and GitHub Actions isn't clever
35+
# enough to detect that it should be skipped, and therefore pass (like they
36+
# allow for skipping jobs in a workflow).
37+
# Therefore, we have to move path filters/globs down to an actual job, and
38+
# emit an output that can be used to skip irrelevant jobs.
39+
detect-changes:
40+
name: Detect relevant changed files
41+
runs-on: ubuntu-latest
42+
steps:
43+
- name: Checkout Repository
44+
uses: stackabletech/actions/detect-changes@a1ab9bf951cf97728f0efaa58ba2105ad955e2e3 # v0.11.0
45+
with:
46+
persist-credentials: false
47+
submodules: recursive
48+
fetch-depth: 0
49+
50+
- name: Check for changed files
51+
id: check
52+
uses: ./.github/actions/detect-changes
53+
with:
54+
patterns: |
55+
- '.github/workflows/build.yaml'
56+
- 'rust-toolchain.toml'
57+
- '.dockerignore'
58+
- 'deploy/**'
59+
- '.cargo/**'
60+
- 'docker/**'
61+
- 'Cargo.*'
62+
- '*.rs'
63+
outputs:
64+
detected: ${{ steps.check.outputs.detected }}
65+
4266
cargo-udeps:
4367
name: Run cargo-udeps
68+
if: needs.detect-changes.outputs.detected == 'true'
69+
needs: [detect-changes]
4470
runs-on: ubuntu-latest
4571
env:
4672
RUSTC_BOOTSTRAP: 1
@@ -76,7 +102,8 @@ jobs:
76102

77103
build-container-image:
78104
name: Build/Publish ${{ matrix.runner.arch }} Image
79-
if: github.event_name != 'merge_group'
105+
if: (github.event_name != 'merge_group') && needs.detect-changes.outputs.detected == 'true'
106+
needs: [detect-changes]
80107
permissions:
81108
id-token: write
82109
strategy:
@@ -159,8 +186,9 @@ jobs:
159186

160187
publish-index-manifest:
161188
name: Publish/Sign ${{ needs.build-container-image.outputs.operator-version }} Index
162-
if: github.event_name != 'merge_group'
189+
if: (github.event_name != 'merge_group') && needs.detect-changes.outputs.detected == 'true'
163190
needs:
191+
- detect-changes
164192
- build-container-image
165193
permissions:
166194
id-token: write
@@ -182,8 +210,9 @@ jobs:
182210

183211
publish-helm-chart:
184212
name: Package/Publish ${{ needs.build-container-image.outputs.operator-version }} Helm Chart
185-
if: github.event_name != 'merge_group'
213+
if: (github.event_name != 'merge_group') && needs.detect-changes.outputs.detected == 'true'
186214
needs:
215+
- detect-changes
187216
- build-container-image
188217
permissions:
189218
id-token: write
@@ -208,8 +237,9 @@ jobs:
208237

209238
openshift-preflight-check:
210239
name: Run OpenShift Preflight Check for ${{ needs.build-container-image.outputs.operator-version }}-${{ matrix.arch }}
211-
if: github.event_name != 'merge_group'
240+
if: (github.event_name != 'merge_group') && needs.detect-changes.outputs.detected == 'true'
212241
needs:
242+
- detect-changes
213243
- build-container-image
214244
- publish-index-manifest
215245
strategy:
@@ -243,8 +273,9 @@ jobs:
243273

244274
notify:
245275
name: Failure Notification
246-
if: (failure() || github.run_attempt > 1) && github.event_name != 'merge_group'
276+
if: (failure() || github.run_attempt > 1) && github.event_name != 'merge_group' && needs.detect-changes.outputs.detected == 'true'
247277
needs:
278+
- detect-changes
248279
- build-container-image
249280
- publish-index-manifest
250281
- publish-helm-chart

0 commit comments

Comments
 (0)