Link Checker #202
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: | |
workflow_dispatch: {} | |
push: | |
branches: ["main"] | |
paths: | |
- ".github/workflows/link-checker.yaml" | |
- "website/**" | |
schedule: | |
- cron: "0 0 * * *" # Every day at midnight | |
env: | |
WORKFLOW_ISSUE_TITLE: "Link Checker Dashboard 🔗" | |
jobs: | |
build-site: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- name: Install jekyll and bundler | |
run: | | |
sudo gem install bundler jekyll | |
bundler --version | |
jekyll --version | |
- name: Install gems | |
run: sudo bundle install --gemfile=website/Gemfile | |
- name: Run jekyll build | |
run: | | |
cd website/ | |
bundle exec jekyll build --trace | |
- name: Upload built site to artifacts | |
uses: actions/upload-artifact@50769540e7f4bd5e21e526ee35c689e35e0d6874 # v4.4.0 | |
with: | |
name: "${{ github.sha }}" | |
path: website/_site/ | |
link-checker: | |
runs-on: ubuntu-latest | |
needs: [build-site] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
- 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@2b973e86fc7b1f6b36a93795fe2c9c6ae1118621 # v1.10.0 | |
with: | |
args: --config=.github/configs/lychee.toml './site/**/*.html' | |
format: markdown | |
output: lychee.md | |
fail: false | |
- name: Generate Token | |
uses: actions/create-github-app-token@3378cda945da322a8db4b193e19d46352ebe2de5 # v1.10.4 | |
id: app-token | |
with: | |
app-id: "${{ secrets.BOT_APP_ID }}" | |
private-key: "${{ secrets.BOT_APP_PRIVATE_KEY }}" | |
- name: Find Link Checker Issue | |
id: find-issue | |
run: | | |
issue_number=$( \ | |
gh issue list \ | |
--search "in:title ${{ env.WORKFLOW_ISSUE_TITLE }}" \ | |
--state open \ | |
--json number \ | |
| 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@24452a72d85239eacf1468b0f1982a9f3fec4c94 # v5.0.0 | |
with: | |
token: "${{ steps.app-token.outputs.token }}" | |
title: "${{ env.WORKFLOW_ISSUE_TITLE }}" | |
issue-number: "${{ steps.find-issue.outputs.issue-number || '' }}" | |
content-filepath: lychee.md |