-
Notifications
You must be signed in to change notification settings - Fork 8
79 lines (65 loc) · 2.43 KB
/
check-links-in-prod.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# This workflow verifies hyperlinks using the deployed
# docs site. It has to be triggered manually.
name: Check links
on:
workflow_dispatch: {}
schedule:
- cron: '39 0 20 * *' # every 20th of the month at 00:39
env:
# space-separated list of the top-level sections to check in https://docs.giantswarm.io/{section}/
SECTIONS: 'getting-started overview reference support tutorials'
jobs:
check-links:
runs-on: ubuntu-latest
steps:
- name: Pull image
run: docker pull ghcr.io/linkchecker/linkchecker:latest
- name: Create output folder
run: |
mkdir -p output
chmod 777 output
- name: check-links-in-overview-pages
shell: python {0}
continue-on-error: true
run: |
import os
import subprocess
pwd = os.getcwd()
sections = os.getenv('SECTIONS').split()
for i, section in enumerate(sections):
# call docker run command
cmd = ['docker', 'run', '--rm', '--name', 'linkchecker',
'--volume', f'{pwd}/output:/workdir', '--workdir', '/workdir',
'ghcr.io/linkchecker/linkchecker:latest',
f'https://docs.giantswarm.io/{section}/',
'--check-extern',
'--threads 1',
'--recursion-level 2',
'--no-status',
'--file-output html/utf8/{section}.html']
result = subprocess.run(cmd)
if result.returncode > 0:
env_file = os.getenv('GITHUB_ENV')
with open(env_file, 'a') as f:
f.write(f"failed{i}=true\n")
- name: Store reports as artifacts
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.2
with:
name: link-check-reports
path: ./output
if-no-files-found: warn
retention-days: 14
- name: Report errors
shell: python {0}
run: |
import sys
import os
found_error = False
sections = os.getenv('SECTIONS').split()
for i, section in enumerate(sections):
failed = os.getenv(f"failed{i}")
if failed == "true":
print(f"Found link errors in the {section} section. Please download the report artifact and fix.")
found_error = True
if found_error:
sys.exit(1)