Skip to content

Commit d2135cf

Browse files
Add reusable workflow for checking changed file paths
1 parent 0376fe0 commit d2135cf

3 files changed

Lines changed: 45 additions & 38 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Determines whether changed files are relevant to Chromatic.
2+
# Both dcr-chromatic.yml and chromatic-label-helper.yml call this so the filter
3+
# list stays in one place and can't drift between the two workflows.
4+
5+
name: Check Chromatic paths
6+
7+
on:
8+
workflow_call:
9+
outputs:
10+
relevant:
11+
description: "'true' if any files relevant to visual rendering have changed"
12+
value: ${{ jobs.filter.outputs.relevant }}
13+
14+
jobs:
15+
filter:
16+
name: Check changed paths
17+
runs-on: ubuntu-latest
18+
outputs:
19+
relevant: ${{ steps.filter.outputs.relevant }}
20+
steps:
21+
- uses: actions/checkout@v6
22+
with:
23+
fetch-depth: 0
24+
- uses: dorny/paths-filter@v4
25+
id: filter
26+
with:
27+
# Only run Chromatic if files that affect visual rendering have changed.
28+
# Everything not listed here (docs, scripts, config, tests, etc.) is ignored.
29+
filters: |
30+
relevant:
31+
- 'dotcom-rendering/src/**'
32+
- 'dotcom-rendering/stories/**'
33+
- 'dotcom-rendering/.storybook/**'
34+
- 'dotcom-rendering/fixtures/**'
35+
- 'dotcom-rendering/package.json'
36+
- 'libs/**'
37+
- 'pnpm-lock.yaml'

.github/workflows/chromatic-label-helper.yml

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,20 @@ name: Chromatic Label Helper
88
on:
99
pull_request:
1010
types: [opened, ready_for_review]
11-
paths-ignore:
12-
- 'ab-testing/**'
13-
- 'scripts/**'
14-
- 'dotcom-rendering/cdk/**'
15-
- 'dotcom-rendering/cypress/**'
16-
- 'dotcom-rendering/docs/**'
17-
- 'dotcom-rendering/logs/**'
18-
- 'dotcom-rendering/playwright/**'
19-
- 'dotcom-rendering/playwright-report/**'
20-
- 'dotcom-rendering/scripts/**'
21-
- 'dotcom-rendering/test-results/**'
22-
- 'dotcom-rendering/__mocks__/**'
23-
- '**.md'
24-
- '**.yml'
25-
- '**/*.d.ts'
2611

2712
jobs:
13+
check-paths:
14+
name: Check changed paths
15+
uses: ./.github/workflows/check-chromatic-paths.yml
16+
2817
write_comment:
2918
runs-on: ubuntu-latest
19+
needs: check-paths
3020
permissions:
3121
pull-requests: write
3222

33-
# We only comment on pull requests that have been marked as ready for review
34-
if: ${{ github.event.pull_request.draft == false}}
23+
# Only comment when the PR touches files relevant to Chromatic and isn't a draft
24+
if: ${{ github.event.pull_request.draft == false && needs.check-paths.outputs.relevant == 'true' }}
3525

3626
steps:
3727
- uses: actions/github-script@v8

.github/workflows/dcr-chromatic.yml

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -9,27 +9,7 @@ on:
99
jobs:
1010
check-paths:
1111
name: Check changed paths
12-
runs-on: ubuntu-latest
13-
outputs:
14-
relevant: ${{ steps.filter.outputs.relevant }}
15-
steps:
16-
- uses: actions/checkout@v6
17-
with:
18-
fetch-depth: 0
19-
- uses: dorny/paths-filter@v4
20-
id: filter
21-
with:
22-
# Only run Chromatic if files that affect visual rendering have changed.
23-
# Everything not listed here (docs, scripts, config, tests, etc.) is ignored.
24-
filters: |
25-
relevant:
26-
- 'dotcom-rendering/src/**'
27-
- 'dotcom-rendering/stories/**'
28-
- 'dotcom-rendering/.storybook/**'
29-
- 'dotcom-rendering/fixtures/**'
30-
- 'dotcom-rendering/package.json'
31-
- 'libs/**'
32-
- 'pnpm-lock.yaml'
12+
uses: ./.github/workflows/check-chromatic-paths.yml
3313

3414
chromatic:
3515
name: Chromatic

0 commit comments

Comments
 (0)