Broken Link Checker #35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Broken Link Checker | |
# Workflow triggers | |
on: | |
schedule: | |
# Run at 5:00 AM on Monday and Friday | |
- cron: '0 5 * * 1,5' | |
# Allow manual triggering | |
workflow_dispatch: | |
jobs: | |
check-links: | |
runs-on: ubuntu-latest | |
name: Check for broken and insecure links | |
timeout-minutes: 30 # Add timeout to prevent hanging | |
# Need permissions to create issues and push changes | |
permissions: | |
contents: write | |
issues: write | |
steps: | |
# Step 1: Checkout repository | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Fetch all history for proper updating | |
# Step 2: Set up Python environment | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.11' | |
# Step 3: Install required Python packages | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install requests markdown beautifulsoup4 PyGithub | |
# Step 4: Configure Git | |
- name: Configure Git | |
run: | | |
git config user.name "GitHub Actions Bot" | |
git config user.email "actions@github.com" | |
# Step 5: Execute link checker script | |
- name: Run link checker | |
env: | |
GITHUB_TOKEN: ${{ secrets.CHECKER_TOKEN }} | |
run: python ./.github/scripts/link_checker.py | |
# Step 6: Commit and push cache updates | |
- name: Commit cache changes | |
run: | | |
git add .github/scripts/link_check_cache.json | |
git commit -m "Update link check cache" || echo "No changes to commit" | |
git push |