Skip to content

Check links

Check links #134

Workflow file for this run

name: Check links
on:
schedule:
- cron: '16 2 * * 6'
jobs:
validate:
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
env:
issue-lookup-label: automated-link-issue
issue-content: ./lychee-out.md
steps:
- name: Get current year
run: echo "CURRENT_YEAR=$(date +'%Y')" >> $GITHUB_ENV
- name: Get next year
run: echo "NEXT_YEAR=$(date -d '+1 year' +'%Y')" >> $GITHUB_ENV
- uses: actions/checkout@v4
- name: Restore lychee cache
uses: actions/cache@v4
with:
path: .lycheecache
key: cache-lychee-${{ github.sha }}
restore-keys: cache-lychee-
- name: Link Checker
id: lychee
uses: lycheeverse/[email protected]
with:
fail: true
args: --cache --verbose --no-progress './conferences/${{ env.CURRENT_YEAR }}/**/*.json' './conferences/${{ env.NEXT_YEAR }}/**/*.json'
output: ${{ env.issue-content }}
- name: Comment Broken Links
if: ${{ failure() }}
uses: marocchino/sticky-pull-request-comment@v2
with:
path: ${{ env.issue-content }}
GITHUB_TOKEN: ${{ secrets.BROKEN_LINK }}
# Permissions (issues: read)
- name: 'Look for an existing issue'
if: ${{ failure() }}
id: last-issue
uses: micalevisk/last-issue-action@v2
# Find the last updated open issue with a `automated-issue` label:
with:
state: open
labels: ${{ env.issue-lookup-label }}
# Permissions (issues: write)
- name: 'Create a new issue, or update an existing one'
if: ${{ failure() }}
uses: peter-evans/create-issue-from-file@v4
with:
title: 'docs: Broken links found'
content-filepath: ${{ env.issue-content }}
token: ${{ secrets.BROKEN_LINK }}
# Update an existing issue if one was found (issue_number),
# otherwise an empty value creates a new issue:
issue-number: ${{ steps['last-issue']['outputs']['issue-number'] }}
# Add a label(s) that `last-issue` can use to find this issue,
# and any other relevant labels for the issue itself:
labels: |
${{ env.issue-lookup-label }}
broken-link, docs