88 push :
99 branches :
1010 - main
11- paths :
12- - " .github/workflows/lint-shellcheck-formatting.yml"
13- - " **/*.sh"
1411
1512 pull_request :
16- paths :
17- - " .github/workflows/lint-shellcheck-formatting.yml"
18- - " **/*.sh"
1913
2014# Concurrency configuration:
2115# - We use workflow-specific concurrency groups to prevent multiple lint runs on the same code,
@@ -29,9 +23,44 @@ concurrency:
2923 cancel-in-progress : ${{ github.event_name == 'pull_request' }}
3024
3125jobs :
26+ files-changed :
27+ name : Detect File Changes
28+ runs-on : ubuntu-latest
29+ outputs :
30+ run_lint_shellcheck_for_prs : ${{ steps.changes.outputs.run_lint_shellcheck_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+
3240 lint :
3341 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_shellcheck_for_prs == 'true'
44+ needs : files-changed
3445 runs-on : ubuntu-latest
3546 steps :
3647 - uses : actions/checkout@v5
3748 - run : shellcheck **/*.sh
49+
50+ lint-shellcheck-required-check :
51+ needs :
52+ [
53+ files-changed,
54+ lint,
55+ ]
56+ name : Lint Shellcheck
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 shellcheck jobs has failed." && exit 1
0 commit comments