8
8
push :
9
9
branches :
10
10
- main
11
- paths :
12
- - " **/*.yml"
13
- - " **/*.yaml"
14
- - " **/*.json"
15
- - " **/*.md"
16
- - " .github/workflows/lint-dprint-formatting.yml"
17
- - " dprint.json"
18
11
19
12
pull_request :
20
- paths :
21
- - " **/*.yml"
22
- - " **/*.yaml"
23
- - " **/*.json"
24
- - " **/*.md"
25
- - " .github/workflows/lint-dprint-formatting.yml"
26
- - " dprint.json"
27
13
28
14
# Concurrency configuration:
29
15
# - We use workflow-specific concurrency groups to prevent multiple lint runs on the same code,
@@ -37,9 +23,44 @@ concurrency:
37
23
cancel-in-progress : ${{ github.event_name == 'pull_request' }}
38
24
39
25
jobs :
26
+ files-changed :
27
+ name : Detect File Changes
28
+ runs-on : ubuntu-latest
29
+ outputs :
30
+ run_lint_dprint_for_prs : ${{ steps.changes.outputs.run_lint_dprint_for_prs }}
31
+ steps :
32
+ - uses : actions/checkout@v5
33
+ - name : Get changed files
34
+ id : changes
35
+ uses : dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
36
+ with :
37
+ token : ${{ github.token }}
38
+ filters : .github/file-filters.yml
39
+
40
40
lint :
41
41
name : Lint
42
+ # Run the job only for PRs with related changes or non-PR events.
43
+ if : github.event_name != 'pull_request' || needs.files-changed.outputs.run_lint_dprint_for_prs == 'true'
44
+ needs : files-changed
42
45
runs-on : ubuntu-latest
43
46
steps :
44
47
- uses : actions/checkout@v5
45
48
49
+
50
+ lint-dprint-required-check :
51
+ needs :
52
+ [
53
+ files-changed,
54
+ lint,
55
+ ]
56
+ name : Lint dprint
57
+ # This is necessary since a failed/skipped dependent job would cause this job to be skipped
58
+ if : always()
59
+ runs-on : ubuntu-latest
60
+ steps :
61
+ # If any jobs we depend on fails gets cancelled or times out, this job will fail.
62
+ # Skipped jobs are not considered failures.
63
+ - name : Check for failures
64
+ if : contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled')
65
+ run : |
66
+ echo "One of the lint dprint jobs has failed." && exit 1
0 commit comments