Skip to content

Check Links

Check Links #21

Workflow file for this run

name: Check Links
on:
# Run weekly on Sunday at 00:00 UTC
schedule:
- cron: '0 0 * * 0'
# Allow manual trigger
workflow_dispatch:
jobs:
check-links:
name: Check for dead links
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Check for dead links
run: npm run lint:urls
continue-on-error: true
- name: Create issue on failure
if: failure()
uses: actions/github-script@v7
with:
script: |
const title = 'Dead links detected in README';
const body = `The weekly link checker found dead links in the README.
Please run \`npm run lint:urls\` locally to see which links are broken.
This issue was automatically created by the link-checker workflow.`;
// Check if issue already exists
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
labels: 'dead-link'
});
const existingIssue = issues.data.find(issue => issue.title === title);
if (!existingIssue) {
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['dead-link', 'maintenance']
});
}