Skip to content

Commit 7953c95

Browse files
committed
ci: improve check-links workflow
1 parent 976ff62 commit 7953c95

1 file changed

Lines changed: 22 additions & 25 deletions

File tree

.github/workflows/check-links.yml

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,48 +3,45 @@ on:
33
push:
44
branches: [ main ]
55
pull_request:
6+
paths:
7+
- '**/*.md'
8+
- '.github/workflows/check-links.yml'
9+
- '.github/workflows/check_links_config.json'
610

711
permissions:
812
contents: read
913

14+
concurrency:
15+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
16+
cancel-in-progress: true
17+
1018
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
2619
check-links:
2720
runs-on: ubuntu-latest
28-
needs: changedfiles
29-
if: >-
30-
${{
31-
github.event.pull_request.user.login != 'otelbot[bot]' &&
32-
github.event_name == 'pull_request' &&
33-
needs.changedfiles.outputs.md
34-
}}
21+
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'otelbot[bot]' }}
22+
timeout-minutes: 15
3523
steps:
3624
- name: Checkout Repo
37-
uses: actions/checkout@v4
25+
uses: actions/checkout@v6
3826
with:
3927
fetch-depth: 0
4028

29+
- name: Get changed markdown files
30+
id: changed-files
31+
uses: tj-actions/changed-files@v46
32+
with:
33+
files: |
34+
**/*.md
35+
4136
- name: Install markdown-link-check
37+
if: steps.changed-files.outputs.any_changed == 'true'
4238
run: npm install -g markdown-link-check@v3.12.2
4339

4440
- name: Run markdown-link-check
41+
if: steps.changed-files.outputs.any_changed == 'true'
4542
run: |
4643
markdown-link-check \
4744
--verbose \
4845
--config .github/workflows/check_links_config.json \
49-
${{ needs.changedfiles.outputs.md }} \
50-
|| { echo "Check that anchor links are lowercase"; exit 1; }
46+
${{ steps.changed-files.outputs.all_changed_files }} \
47+
|| { echo "Check that anchor links are lowercase"; exit 1; }

0 commit comments

Comments
 (0)