Link Checker #324
This file contains 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
--- | |
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json | |
name: Link Checker | |
on: | |
# Manual Trigger | |
workflow_dispatch: | |
inputs: | |
dry-run: | |
description: Dry Run | |
default: true | |
required: false | |
type: boolean | |
# Dry Run on any PR that modifies the workflow, the dockerfile or the site contents | |
pull_request: | |
paths: | |
- ".github/workflows/link-checker.yaml" | |
- "website/**" | |
# "Wet" run daily at midnight | |
schedule: | |
- cron: "0 0 * * *" | |
env: | |
WORKFLOW_ISSUE_TITLE: "Link Checker Dashboard 🔗" | |
jobs: | |
build-site: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Ruby | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: "3.3" | |
- name: Generate Token | |
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1 | |
id: app-token | |
with: | |
app-id: "${{ secrets.BOT_APP_ID }}" | |
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
token: "${{ steps.app-token.outputs.token }}" | |
- name: Install jekyll and bundler | |
run: gem install bundler jekyll | |
- name: Show bundler version | |
run: bundler --version | |
- name: Show jekyll version | |
run: jekyll --version | |
- name: Install gems | |
run: bundle install --gemfile=website/Gemfile | |
- name: Run jekyll build | |
working-directory: ./website | |
run: bundle exec jekyll build --trace | |
- name: Upload built site to artifacts | |
uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4.5.0 | |
with: | |
name: "${{ github.sha }}" | |
path: website/_site/ | |
link-checker: | |
runs-on: ubuntu-latest | |
needs: [build-site] | |
steps: | |
- name: Generate Token | |
uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1.11.1 | |
id: app-token | |
with: | |
app-id: "${{ secrets.BOT_APP_ID }}" | |
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" | |
- name: Checkout | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
token: "${{ steps.app-token.outputs.token }}" | |
- name: Download Site Files | |
uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4.1.8 | |
with: | |
path: ./site | |
- name: Check Links | |
id: link-checker | |
uses: lycheeverse/lychee-action@f796c8b7d468feb9b8c0a46da3fac0af6874d374 # v2.2.0 | |
with: | |
args: --config=lychee.toml './site/**/*.html' | |
format: markdown | |
output: lychee.md | |
fail: false | |
- name: Find Link Checker Issue | |
id: find-issue | |
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.dry-run == 'false') || github.event_name == 'schedule' }} | |
run: | | |
gh_output=$(gh issue list --state=open --json=number --search="in:title $WORKFLOW_ISSUE_TITLE") | |
issue_number=$(echo "$gh_output" | jq --raw-output '.[0].number') | |
echo "issue-number=${issue_number}" >> "$GITHUB_OUTPUT" | |
echo "${issue_number}" | |
env: | |
GH_TOKEN: "${{ steps.app-token.outputs.token }}" | |
- name: Create or Update Issue | |
uses: peter-evans/create-issue-from-file@e8ef132d6df98ed982188e460ebb3b5d4ef3a9cd # v5.0.1 | |
if: ${{ (github.event_name == 'workflow_dispatch' && github.event.inputs.dry-run == 'false') || github.event_name == 'schedule' }} | |
with: | |
token: "${{ steps.app-token.outputs.token }}" | |
title: "${{ env.WORKFLOW_ISSUE_TITLE }}" | |
issue-number: "${{ steps.find-issue.outputs.issue-number || '' }}" | |
content-filepath: lychee.md |