88 push :
99 branches :
1010 - main
11- paths :
12- - " **/*.yml"
13- - " **/*.yaml"
14- - " **/*.json"
15- - " **/*.md"
16- - " .github/workflows/lint-dprint-formatting.yml"
17- - " dprint.json"
1811
1912 pull_request :
20- paths :
21- - " **/*.yml"
22- - " **/*.yaml"
23- - " **/*.json"
24- - " **/*.md"
25- - " .github/workflows/lint-dprint-formatting.yml"
26- - " dprint.json"
2713
2814# Concurrency configuration:
2915# - We use workflow-specific concurrency groups to prevent multiple lint runs on the same code,
@@ -37,9 +23,44 @@ concurrency:
3723 cancel-in-progress : ${{ github.event_name == 'pull_request' }}
3824
3925jobs :
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+
4040 lint :
4141 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
4245 runs-on : ubuntu-latest
4346 steps :
4447 - uses : actions/checkout@v5
4548 - uses : dprint/check@v2.3
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