|
3 | 3 | push: |
4 | 4 | branches: [ main ] |
5 | 5 | pull_request: |
| 6 | + paths: |
| 7 | + - '**/*.md' |
| 8 | + - '.github/workflows/check-links.yml' |
| 9 | + - '.github/workflows/check_links_config.json' |
6 | 10 |
|
7 | 11 | permissions: |
8 | 12 | contents: read |
9 | 13 |
|
| 14 | +concurrency: |
| 15 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }} |
| 16 | + cancel-in-progress: true |
| 17 | + |
10 | 18 | jobs: |
11 | | - changedfiles: |
12 | | - name: changed files |
13 | | - runs-on: ubuntu-latest |
14 | | - if: ${{ github.actor != 'dependabot[bot]' }} |
15 | | - outputs: |
16 | | - md: ${{ steps.changes.outputs.md }} |
17 | | - steps: |
18 | | - - name: Checkout Repo |
19 | | - uses: actions/checkout@v4 |
20 | | - with: |
21 | | - fetch-depth: 0 |
22 | | - - name: Get changed files |
23 | | - id: changes |
24 | | - run: | |
25 | | - echo "md=$(git diff --name-only --diff-filter=ACMRTUXB $(git merge-base origin/main ${{ github.event.pull_request.head.sha }}) ${{ github.event.pull_request.head.sha }} | grep .md$ | xargs)" >> $GITHUB_OUTPUT |
26 | 19 | check-links: |
27 | 20 | runs-on: ubuntu-latest |
28 | | - needs: changedfiles |
29 | | - if: | |
30 | | - github.event.pull_request.user.login != 'otelbot[bot]' && github.event_name == 'pull_request' |
31 | | - && ${{needs.changedfiles.outputs.md}} |
| 21 | + timeout-minutes: 15 |
| 22 | + if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'otelbot[bot]' }} |
32 | 23 | steps: |
33 | 24 | - name: Checkout Repo |
34 | | - uses: actions/checkout@v4 |
| 25 | + uses: actions/checkout@v6 |
| 26 | + |
| 27 | + - name: Get changed markdown files |
| 28 | + id: changed-files |
| 29 | + uses: tj-actions/changed-files@v46 |
35 | 30 | with: |
36 | | - fetch-depth: 0 |
| 31 | + files: | |
| 32 | + **/*.md |
37 | 33 |
|
38 | 34 | - name: Install markdown-link-check |
| 35 | + if: steps.changed-files.outputs.any_changed == 'true' |
39 | 36 | run: npm install -g markdown-link-check@v3.12.2 |
40 | 37 |
|
41 | 38 | - name: Run markdown-link-check |
| 39 | + if: steps.changed-files.outputs.any_changed == 'true' |
| 40 | + env: |
| 41 | + CHANGED_MARKDOWN_FILES: ${{ steps.changed-files.outputs.all_changed_files }} |
42 | 42 | run: | |
43 | | - markdown-link-check \ |
| 43 | + printf '%s\n' "$CHANGED_MARKDOWN_FILES" | tr ' ' '\n' | xargs -r -n 1 -P 4 markdown-link-check \ |
44 | 44 | --verbose \ |
45 | 45 | --config .github/workflows/check_links_config.json \ |
46 | | - ${{needs.changedfiles.outputs.md}} \ |
47 | 46 | || { echo "Check that anchor links are lowercase"; exit 1; } |
0 commit comments