|
7 | 7 |
|
8 | 8 | permissions: |
9 | 9 | contents: read |
10 | | - |
| 10 | + pull-requests: read |
11 | 11 | concurrency: |
12 | 12 | group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
13 | 13 | cancel-in-progress: true |
14 | 14 |
|
15 | 15 | jobs: |
| 16 | + detect-markdown-only: |
| 17 | + name: Detect markdown-only changes |
| 18 | + runs-on: ubuntu-latest |
| 19 | + outputs: |
| 20 | + markdown_only: ${{ steps.detect.outputs.markdown_only }} |
| 21 | + steps: |
| 22 | + - name: Detect markdown-only PR |
| 23 | + id: detect |
| 24 | + env: |
| 25 | + GH_TOKEN: ${{ github.token }} |
| 26 | + PR_NUMBER: ${{ github.event.pull_request.number }} |
| 27 | + REPOSITORY: ${{ github.repository }} |
| 28 | + EVENT_NAME: ${{ github.event_name }} |
| 29 | + run: | |
| 30 | + if [ "$EVENT_NAME" != "pull_request" ]; then |
| 31 | + echo "markdown_only=false" >> "$GITHUB_OUTPUT" |
| 32 | + exit 0 |
| 33 | + fi |
| 34 | +
|
| 35 | + gh api --paginate "repos/$REPOSITORY/pulls/$PR_NUMBER/files" --jq '.[].filename' > "$RUNNER_TEMP/changed-files.txt" |
| 36 | +
|
| 37 | + if [ ! -s "$RUNNER_TEMP/changed-files.txt" ]; then |
| 38 | + markdown_only=false |
| 39 | + elif grep -qvE '\.md$' "$RUNNER_TEMP/changed-files.txt"; then |
| 40 | + markdown_only=false |
| 41 | + else |
| 42 | + markdown_only=true |
| 43 | + fi |
| 44 | +
|
| 45 | + echo "markdown_only=$markdown_only" >> "$GITHUB_OUTPUT" |
| 46 | + echo "markdown_only=$markdown_only" |
| 47 | +
|
16 | 48 | build: |
| 49 | + needs: detect-markdown-only |
17 | 50 | name: Build Job |
18 | 51 | runs-on: ubuntu-latest |
19 | 52 |
|
20 | 53 | steps: |
| 54 | + - name: Skip expensive CI for markdown-only PR |
| 55 | + if: needs.detect-markdown-only.outputs.markdown_only == 'true' |
| 56 | + run: echo "Only Markdown files changed; marking this check successful without running expensive CI." |
21 | 57 | - name: Git checkout |
| 58 | + if: needs.detect-markdown-only.outputs.markdown_only != 'true' |
22 | 59 | uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3 |
23 | 60 |
|
24 | 61 | - name: 'Set up Java 17' |
| 62 | + if: needs.detect-markdown-only.outputs.markdown_only != 'true' |
25 | 63 | uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0 |
26 | 64 | with: |
27 | 65 | java-version: '17' |
28 | 66 | distribution: 'temurin' |
29 | 67 |
|
30 | 68 | - name: Cache Gradle packages |
| 69 | + if: needs.detect-markdown-only.outputs.markdown_only != 'true' |
31 | 70 | uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5 |
32 | 71 | with: |
33 | 72 | path: | |
|
38 | 77 | ${{ runner.os }}-gradle- |
39 | 78 |
|
40 | 79 | - name: Make compile |
| 80 | + if: needs.detect-markdown-only.outputs.markdown_only != 'true' |
41 | 81 | run: make compile |
42 | 82 |
|
43 | 83 | - name: Make stop |
| 84 | + if: needs.detect-markdown-only.outputs.markdown_only != 'true' |
44 | 85 | run: make stop |
0 commit comments