|
| 1 | +name: Links |
| 2 | + |
| 3 | +on: |
| 4 | + repository_dispatch: |
| 5 | + workflow_dispatch: |
| 6 | + pull_request: |
| 7 | + schedule: |
| 8 | + - cron: "00 18 * * *" |
| 9 | + |
| 10 | +jobs: |
| 11 | + linkChecker: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + issues: write # required for peter-evans/create-issue-from-file |
| 15 | + pull-requests: write # required for github-script to comment on PRs |
| 16 | + steps: |
| 17 | + - uses: actions/checkout@v5 |
| 18 | + |
| 19 | + - name: Link Checker |
| 20 | + id: lychee |
| 21 | + uses: lycheeverse/lychee-action@v2 |
| 22 | + with: |
| 23 | + args: . --exclude-path "tests" |
| 24 | + fail: false |
| 25 | + |
| 26 | + # - name: Create or Update PR Comment |
| 27 | + # if: steps.lychee.outputs.exit_code != 0 && github.event_name == 'pull_request' |
| 28 | + # uses: actions/github-script@v8 |
| 29 | + # with: |
| 30 | + # script: | |
| 31 | + # const fs = require('fs'); |
| 32 | + # const commentMarker = '<!-- link-checker-report -->'; |
| 33 | + |
| 34 | + # // Read the report file if it exists, otherwise use a fallback message |
| 35 | + # let body; |
| 36 | + # if (fs.existsSync('./lychee/out.md')) { |
| 37 | + # body = fs.readFileSync('./lychee/out.md', 'utf8'); |
| 38 | + # } else { |
| 39 | + # body = '## 🔗 Link Checker Report\n\nThe link checker found broken links in this pull request. Please check the workflow logs for details.'; |
| 40 | + # } |
| 41 | + |
| 42 | + # // Add the marker to identify this comment |
| 43 | + # body = commentMarker + '\n\n' + body; |
| 44 | + |
| 45 | + # // Get existing comments on the PR |
| 46 | + # const { data: comments } = await github.rest.issues.listComments({ |
| 47 | + # owner: context.repo.owner, |
| 48 | + # repo: context.repo.repo, |
| 49 | + # issue_number: context.issue.number, |
| 50 | + # }); |
| 51 | + |
| 52 | + # // Find existing comment with our marker |
| 53 | + # const existingComment = comments.find(comment => |
| 54 | + # comment.user.type === 'Bot' && |
| 55 | + # comment.body.includes(commentMarker) |
| 56 | + # ); |
| 57 | + |
| 58 | + # if (existingComment) { |
| 59 | + # // Update existing comment |
| 60 | + # await github.rest.issues.updateComment({ |
| 61 | + # owner: context.repo.owner, |
| 62 | + # repo: context.repo.repo, |
| 63 | + # comment_id: existingComment.id, |
| 64 | + # body: body, |
| 65 | + # }); |
| 66 | + # } else { |
| 67 | + # // Create new comment |
| 68 | + # await github.rest.issues.createComment({ |
| 69 | + # owner: context.repo.owner, |
| 70 | + # repo: context.repo.repo, |
| 71 | + # issue_number: context.issue.number, |
| 72 | + # body: body, |
| 73 | + # }); |
| 74 | + # } |
| 75 | + |
| 76 | + # - name: Create Issue From File |
| 77 | + # if: steps.lychee.outputs.exit_code != 0 && github.event_name == 'schedule' |
| 78 | + # uses: peter-evans/create-issue-from-file@v5 |
| 79 | + # with: |
| 80 | + # title: Link Checker Report |
| 81 | + # content-filepath: ./lychee/out.md |
| 82 | + # labels: 'type: documentation' |
0 commit comments