|
5 | 5 | # Runs weekly every Sunday at 05:00 UTC (midnight EST) |
6 | 6 | schedule: |
7 | 7 | - cron: '0 5 * * 0' |
8 | | - # Runs on pull requests targeting the dev branch |
| 8 | + # Runs on pull requests targeting the main branch |
9 | 9 | pull_request: |
10 | 10 | branches: ["main"] |
11 | 11 | # Allows you to run this workflow manually from the Actions tab |
12 | 12 | workflow_dispatch: |
13 | 13 |
|
| 14 | +permissions: |
| 15 | + contents: read |
| 16 | + pull-requests: read |
| 17 | + |
| 18 | +env: |
| 19 | + # --base resolves root-relative paths (e.g. /events/) against the live site |
| 20 | + # --accept includes 403/429 since many destinations (mathworks, hilton, doi.org, |
| 21 | + # slack invites) reject lychee's user-agent rather than the link being broken |
| 22 | + # --insecure: lychee (and sphinx) hit SSL cert issues on INCF URLs |
| 23 | + LYCHEE_ARGS: >- |
| 24 | + --verbose |
| 25 | + --no-progress |
| 26 | + --base 'https://neurodatawithoutborders.github.io/' |
| 27 | + --accept '200..=299,403,429' |
| 28 | + --max-retries 2 |
| 29 | + --insecure |
| 30 | +
|
14 | 31 | jobs: |
15 | | - link_check: |
| 32 | + # Blocking check on the content files a pull request adds or edits. |
| 33 | + pr_link_check: |
| 34 | + if: github.event_name == 'pull_request' |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - name: Checkout |
| 38 | + uses: actions/checkout@v4 |
| 39 | + |
| 40 | + - name: List content files changed by this pull request |
| 41 | + id: changed |
| 42 | + env: |
| 43 | + GH_TOKEN: ${{ github.token }} |
| 44 | + run: | |
| 45 | + files=$(gh api --paginate \ |
| 46 | + "repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}/files" \ |
| 47 | + --jq '.[] | select(.status != "removed") | .filename' \ |
| 48 | + | grep -E '^content/.*\.(md|html|rst)$' \ |
| 49 | + | tr '\n' ' ' || true) |
| 50 | + echo "files=${files}" >> "$GITHUB_OUTPUT" |
| 51 | + echo "Checking: ${files:-(no content files changed)}" |
| 52 | +
|
| 53 | + - name: Link Checker |
| 54 | + if: steps.changed.outputs.files != '' |
| 55 | + uses: lycheeverse/lychee-action@v2 |
| 56 | + with: |
| 57 | + args: ${{ env.LYCHEE_ARGS }} ${{ steps.changed.outputs.files }} |
| 58 | + fail: true |
| 59 | + |
| 60 | + # Advisory sweep of every content file. Archived event pages carry dead links |
| 61 | + # that are triaged separately, so the run reports them in the job summary |
| 62 | + # without failing. |
| 63 | + full_link_check: |
| 64 | + if: github.event_name != 'pull_request' |
16 | 65 | runs-on: ubuntu-latest |
17 | 66 | steps: |
18 | 67 | - name: Checkout |
19 | 68 | uses: actions/checkout@v4 |
20 | 69 |
|
21 | 70 | - name: Link Checker |
22 | | - id: lychee |
23 | 71 | uses: lycheeverse/lychee-action@v2 |
24 | 72 | with: |
25 | | - # --base resolves root-relative paths (e.g. /events/) against the live site |
26 | | - # --accept includes 403/429 since many destinations (mathworks, hilton, doi.org, |
27 | | - # slack invites) reject lychee's user-agent rather than the link being broken |
28 | | - # --insecure: lychee (and sphinx) hit SSL cert issues on INCF URLs |
29 | 73 | args: >- |
30 | | - --verbose |
31 | | - --no-progress |
32 | | - --base 'https://neurodatawithoutborders.github.io/' |
33 | | - --accept '200..=299,403,429' |
34 | | - --max-retries 2 |
35 | | - --insecure |
| 74 | + ${{ env.LYCHEE_ARGS }} |
36 | 75 | './content/**/*.md' |
37 | 76 | './content/**/*.html' |
38 | 77 | './content/**/*.rst' |
39 | | - # Don't block PRs on the report; the job summary still surfaces broken links |
40 | | - # so they can be triaged separately. Pre-existing dead links in archived |
41 | | - # event pages otherwise fail every PR. |
42 | 78 | fail: false |
0 commit comments