|
15 | 15 |
|
16 | 16 | jobs: |
17 | 17 | # ───────────────────────────────────────────────────────────────────────────── |
18 | | - # JOB 0 — check-version (post-merge only) |
| 18 | + # JOB 0 — changes |
| 19 | + # Detects whether any non-docs files changed. When only .md files (or |
| 20 | + # LICENSE / ISSUE_TEMPLATE) are modified, expensive jobs are skipped and |
| 21 | + # report "skipped" (green) so required branch-protection checks are satisfied. |
| 22 | + # ───────────────────────────────────────────────────────────────────────────── |
| 23 | + changes: |
| 24 | + runs-on: ubuntu-latest |
| 25 | + outputs: |
| 26 | + code: ${{ steps.filter.outputs.code }} |
| 27 | + steps: |
| 28 | + - name: Harden the runner (Audit all outbound calls) |
| 29 | + uses: step-security/harden-runner@a90bcbc6539c36a85cdfeb73f7e2f433735f215b # v2.15.0 |
| 30 | + with: |
| 31 | + egress-policy: audit |
| 32 | + |
| 33 | + - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 |
| 34 | + with: |
| 35 | + fetch-depth: 0 |
| 36 | + |
| 37 | + - name: Check for non-docs changes |
| 38 | + id: filter |
| 39 | + run: | |
| 40 | + if [ "${{ github.event_name }}" = "pull_request" ]; then |
| 41 | + BASE="${{ github.event.pull_request.base.sha }}" |
| 42 | + HEAD="${{ github.event.pull_request.head.sha }}" |
| 43 | + else |
| 44 | + BASE="${{ github.event.before }}" |
| 45 | + HEAD="${{ github.sha }}" |
| 46 | + fi |
| 47 | + # No base SHA (force push / first push / workflow_dispatch) → always run |
| 48 | + if [ -z "${BASE}" ] || [ "${BASE}" = "0000000000000000000000000000000000000000" ]; then |
| 49 | + echo "code=true" >> "$GITHUB_OUTPUT" |
| 50 | + echo "No base SHA — treating as code change" |
| 51 | + exit 0 |
| 52 | + fi |
| 53 | + COUNT=$(git diff --name-only "${BASE}" "${HEAD}" \ |
| 54 | + | grep -cvE '^(.*\.md|LICENSE(\.md)?|\.github/ISSUE_TEMPLATE/.*)$' || echo 0) |
| 55 | + echo "code=$([ "${COUNT}" -gt 0 ] && echo 'true' || echo 'false')" >> "$GITHUB_OUTPUT" |
| 56 | + echo "Non-docs changed files: ${COUNT}" |
| 57 | +
|
| 58 | + # ───────────────────────────────────────────────────────────────────────────── |
| 59 | + # JOB 1 — check-version (post-merge only) |
19 | 60 | # Checks whether this push introduces a new version that needs releasing. |
20 | 61 | # All post-merge release jobs (build push, verify, scan, merge, cleanup) are |
21 | 62 | # gated on this output so that pipeline-only merges (no version bump) complete |
@@ -59,9 +100,10 @@ jobs: |
59 | 100 | # ───────────────────────────────────────────────────────────────────────────── |
60 | 101 | build-and-push: |
61 | 102 | runs-on: ubuntu-latest |
62 | | - needs: check-version |
| 103 | + needs: [check-version, changes] |
63 | 104 | if: | |
64 | 105 | always() && |
| 106 | + needs.changes.outputs.code == 'true' && |
65 | 107 | (github.event_name == 'pull_request' || needs.check-version.outputs.is-new-version == 'true') |
66 | 108 | strategy: |
67 | 109 | fail-fast: true |
@@ -550,8 +592,9 @@ jobs: |
550 | 592 | # ───────────────────────────────────────────────────────────────────────────── |
551 | 593 | pre-merge-cd-check: |
552 | 594 | runs-on: ubuntu-latest |
553 | | - needs: build-and-push |
| 595 | + needs: [build-and-push, changes] |
554 | 596 | if: | |
| 597 | + needs.changes.outputs.code == 'true' && |
555 | 598 | github.event_name == 'pull_request' && |
556 | 599 | github.event.pull_request.head.repo.full_name == github.repository |
557 | 600 | permissions: |
|
0 commit comments