diff --git a/.github/workflows/link-checker.yml b/.github/workflows/link-checker.yml new file mode 100644 index 0000000..e9ed796 --- /dev/null +++ b/.github/workflows/link-checker.yml @@ -0,0 +1,29 @@ +name: Check Links + +on: + workflow_call: + +jobs: + linkChecker: + if: github.repository_owner == 'exercism' + runs-on: ubuntu-26.04 + permissions: + issues: write + steps: + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 + + - name: Link Checker + id: lychee + uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 + with: + args: --cache --accept ..=299,429 --suggest --verbose --require-https --user-agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36" --no-progress **/*.md **/*.html **/*.toml **/*.json + fail: false + + - name: Create Issue From File + if: steps.lychee.outputs.exit_code != 0 + uses: peter-evans/create-issue-from-file@fca9117c27cdc29c6c4db3b86c48e4115a786710 # v6.0.0 + with: + title: Link Checker Report + content-filepath: ./lychee/out.md + labels: report, automated issue diff --git a/README.md b/README.md index 815a195..c2dbea6 100644 --- a/README.md +++ b/README.md @@ -343,5 +343,31 @@ jobs: ordering: ".bucket, .slug" ``` +## Reusable workflow: link-checker + +The `link-checker` reusable workflow calls [Lychee][lychee] and creates an issue if any problematic links are reported. + +### Inputs + +None. + +### Example + +To run this on a monthly schedule, in your track repo add this workflow: + +```yaml +name: Check Links + +on: + workflow_dispatch: + schedule: + - cron: 0 0 15 * * # 15th day of each month + +jobs: + call-gha-workflow: + uses: exercism/github-actions/.github/workflow/link-checker.yml@main +``` + [configlet]: https://exercism.org/docs/building/configlet [configlet-lint]: https://exercism.org/docs/building/configlet/lint +[lychee]: https://github.com/lycheeverse/lychee#readme