Skip to content

Broken URL Check

Broken URL Check #26

Workflow file for this run

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