Skip to content

Check Markdown Links #83

Check Markdown Links

Check Markdown Links #83

Workflow file for this run

name: Check Markdown Links
on:
# Run on push to main branches
push:
branches: [ main, develop ]
# Run on pull requests
pull_request:
branches: [ main, develop ]
# Allow manual runs
workflow_dispatch:
# Run weekly to catch links that break over time
schedule:
- cron: '0 6 * * 1' # Every Monday at 6 AM UTC
jobs:
markdown-link-check:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Check links in Hugo site
id: hugo-link-check
uses: tcort/github-action-markdown-link-check@v1
continue-on-error: true
with:
folder-path: 'hugo-site/content'
config-file: '.github/mlc_config.json'
use-quiet-mode: 'yes'
- name: Check links in Gatsby site
id: gatsby-link-check
uses: tcort/github-action-markdown-link-check@v1
continue-on-error: true
with:
folder-path: 'gatsby-site/content'
config-file: '.github/mlc_config.json'
use-quiet-mode: 'yes'
- name: Create issue for broken links
if: failure() && github.event_name == 'schedule'
uses: actions/github-script@v7
with:
script: |
const title = `🔗 Broken links detected - ${new Date().toISOString().split('T')[0]}`;
const body = `## Broken Links Detected
Automated link checking found broken links in the blog posts.
**Run details:**
- Workflow: ${{ github.workflow }}
- Run: ${{ github.run_number }}
- Commit: ${{ github.sha }}
- Date: ${new Date().toISOString()}
**Next steps:**
1. Review the [workflow run logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details
2. Fix the broken links in the affected blog posts
3. Consider updating links to archive.org versions for dead sites
4. Close this issue once all links are fixed
**Sites checked:**
- Hugo site: \`hugo-site/content\`
- Gatsby site: \`gatsby-site/content\`
---
*This issue was automatically created by the link checker workflow.*`;
// Check if there's already an open issue for broken links
const existingIssues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['broken-links'],
state: 'open'
});
if (existingIssues.data.length === 0) {
// Create new issue
const issue = await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: title,
body: body,
labels: ['broken-links', 'automated'],
assignees: ['tmr08c']
});
core.info(`Created issue #${issue.data.number}: ${title}`);
} else {
// Update existing issue
const existingIssue = existingIssues.data[0];
const updateBody = `${existingIssue.body}
---
**Update ${new Date().toISOString().split('T')[0]}:** Broken links still detected in [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})`;
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: existingIssue.number,
body: `🔗 Broken links still detected on ${new Date().toISOString().split('T')[0]}
See [workflow run logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for details.`
});
core.info(`Updated existing issue #${existingIssue.number}`);
}