generated from shuding/nextra-docs-template
-
Notifications
You must be signed in to change notification settings - Fork 29
59 lines (50 loc) · 1.59 KB
/
url_check.yml
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
name: Broken URL Check
on:
schedule:
- cron: '0 0 * * 1'
workflow_dispatch:
jobs:
url-check:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install requests
- name: Run link checker
id: run_checker
run: |
python scripts/urlcheck.py > checker_output.json
cat checker_output.json
env:
CHECK_PATH: './pages/'
- name: Process results
id: process_results
run: |
json_output=$(cat checker_output.json)
echo "Raw output:"
echo "$json_output"
total_issues=$(echo "$json_output" | jq -r '.total_issues')
echo "TOTAL_ISSUES=$total_issues" >> $GITHUB_ENV
if [ "$total_issues" -gt 0 ]; then
issue_table=$(echo "$json_output" | jq -r '.issues[] | "| \(.file) | \(.line) | \(.url) | \(.status_code) | \(.reason) |"' | sed -e 's/^/ /')
echo 'ISSUE_TABLE<<EOF' >> $GITHUB_ENV
echo "$issue_table" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
fi
- name: Create Issue
if: ${{ env.TOTAL_ISSUES > 0 }}
uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: .github/ISSUE_TEMPLATE_URL_CHECK.md