Skip to content

links

links #664

---
name: links
on:
workflow_dispatch:
schedule:
- cron: "0 6 * * *" # Every day at 6am
pull_request:
branches: ["main"]
push:
branches: ["main"]
jobs:
check:
runs-on: ubuntu-20.04
steps:
- name: Generate Token
id: generate-token
uses: tibdex/github-app-token@b62528385c34dbc9f38e5f4225ac829252d1ea92 # v1.8.0
with:
app_id: "${{ secrets.BOT_APP_ID }}"
private_key: "${{ secrets.BOT_APP_PRIVATE_KEY }}"
- name: Checkout repo
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3
- name: Scan for broken links
uses: lycheeverse/lychee-action@ec3ed119d4f44ad2673a7232460dc7dff59d2421 # v1
id: lychee
env:
GITHUB_TOKEN: "${{ steps.app-token.outputs.token }}"
with:
args: >
--verbose
--exclude-mail
'./**/*.md'
- name: Find Broken links issues
id: broken-link-check-issue
uses: micalevisk/last-issue-action@305829d9728f47beb0029417167a0af890edfd6e # v2
with:
state: all
labels: |
broken-links
- name: Update issues
if: env.lychee_exit_code != 0
uses: peter-evans/create-issue-from-file@433e51abf769039ee20ba1293a088ca19d573b7f # v4
with:
title: Broken links detected 🔗
issue-number: "${{ steps.broken-link-check-issue.outputs.issue-number }}"
content-filepath: ./lychee/out.md
token: "${{ steps.generate-token.outputs.token }}"
labels: |
broken-links
- name: Close open issues
if: env.lychee_exit_code == 0 && steps.broken-link-check-issue.outputs.has-found == true
uses: peter-evans/close-issue@276d7966e389d888f011539a86c8920025ea0626 # v3
with:
token: "${{ steps.generate-token.outputs.token }}"
issue-number: "${{ steps.broken-link-check-issue.outputs.issue-number }}"