Skip to content

Commit 498b928

Browse files
apatnivemdneto
andauthored
maint: Add ci workflow to check links (#4432)
* Add ci workflow to check links * Address code review * Add rst files as well * Apply suggestion from @emdneto --------- Co-authored-by: Emídio Neto <9735060+emdneto@users.noreply.github.com>
1 parent 34bfc28 commit 498b928

File tree

2 files changed

+66
-0
lines changed

2 files changed

+66
-0
lines changed

.github/workflows/check-links.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: check-links
2+
on:
3+
push:
4+
branches: [ main ]
5+
paths:
6+
- '**/*.md'
7+
- '**/*.rst'
8+
- '.github/workflows/check-links.yml'
9+
- '.github/workflows/check_links_config.json'
10+
pull_request:
11+
paths:
12+
- '**/*.md'
13+
- '**/*.rst'
14+
- '.github/workflows/check-links.yml'
15+
- '.github/workflows/check_links_config.json'
16+
17+
permissions:
18+
contents: read
19+
20+
concurrency:
21+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
22+
cancel-in-progress: true
23+
24+
jobs:
25+
check-links:
26+
runs-on: ubuntu-latest
27+
if: ${{ github.actor != 'dependabot[bot]' && github.actor != 'otelbot[bot]' }}
28+
timeout-minutes: 15
29+
steps:
30+
- name: Checkout Repo
31+
uses: actions/checkout@v6
32+
33+
- name: Get changed markdown files
34+
id: changed-files
35+
uses: tj-actions/changed-files@v46
36+
with:
37+
files: |
38+
**/*.md
39+
**/*.rst
40+
41+
- name: Install markdown-link-check
42+
if: steps.changed-files.outputs.any_changed == 'true'
43+
run: npm install -g markdown-link-check@v3.12.2
44+
45+
- name: Run markdown-link-check
46+
if: steps.changed-files.outputs.any_changed == 'true'
47+
run: |
48+
markdown-link-check \
49+
--verbose \
50+
--config .github/workflows/check_links_config.json \
51+
${{ steps.changed-files.outputs.all_changed_files }} \
52+
|| { echo "Check that anchor links are lowercase"; exit 1; }
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"ignorePatterns": [
3+
{
4+
"pattern": "http(s)?://\\d+\\.\\d+\\.\\d+\\.\\d+"
5+
},
6+
{
7+
"pattern": "http(s)?://localhost"
8+
},
9+
{
10+
"pattern": "http(s)?://example.com"
11+
}
12+
],
13+
"aliveStatusCodes": [429, 200]
14+
}

0 commit comments

Comments
 (0)