|
| 1 | +# Licensed to the Apache Software Foundation (ASF) under one |
| 2 | +# or more contributor license agreements. See the NOTICE file |
| 3 | +# distributed with this work for additional information |
| 4 | +# regarding copyright ownership. The ASF licenses this file |
| 5 | +# to you under the Apache License, Version 2.0 (the |
| 6 | +# "License"); you may not use this file except in compliance |
| 7 | +# with the License. You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +# To run similar tasks locally, install lychee and run the following at the root of the repository: |
| 19 | +# lychee . |
| 20 | + |
| 21 | +name: Links |
| 22 | + |
| 23 | +on: |
| 24 | + repository_dispatch: |
| 25 | + workflow_dispatch: |
| 26 | + pull_request: |
| 27 | + schedule: |
| 28 | + - cron: '9 1 * * 0' # At 01:09 on Sunday. |
| 29 | + |
| 30 | +jobs: |
| 31 | + check-links: |
| 32 | + runs-on: ubuntu-latest |
| 33 | + permissions: |
| 34 | + issues: write # required for Broken Links Report |
| 35 | + steps: |
| 36 | + - uses: actions/checkout@v6 |
| 37 | + with: |
| 38 | + persist-credentials: false |
| 39 | + - name: Link Checker |
| 40 | + id: lychee |
| 41 | + uses: lycheeverse/lychee-action@8646ba30535128ac92d33dfc9133794bfdd9b411 # v2.8.0 |
| 42 | + with: |
| 43 | + args: --config lychee.toml . |
| 44 | + fail: false |
| 45 | + |
| 46 | + - name: Broken Links Report |
| 47 | + if: steps.lychee.outputs.exit_code != 0 && github.event_name == 'schedule' |
| 48 | + uses: actions/github-script@v8 |
| 49 | + with: |
| 50 | + script: | |
| 51 | + const fs = require('fs'); |
| 52 | +
|
| 53 | + // Read the markdown file |
| 54 | + // Ensure the path is correct relative to the workspace root |
| 55 | + const reportBody = fs.readFileSync('./lychee/out.md', 'utf8'); |
| 56 | +
|
| 57 | + await github.rest.issues.create({ |
| 58 | + owner: context.repo.owner, |
| 59 | + repo: context.repo.repo, |
| 60 | + title: 'Broken Links Report', |
| 61 | + body: reportBody |
| 62 | + }); |
0 commit comments