|
| 1 | +name:Links Checker |
| 2 | + |
| 3 | +on: |
| 4 | +## Allow triggering this workflow manually via GitHub CLI/web |
| 5 | +workflow_dispatch: |
| 6 | + |
| 7 | +## Run this workflow automatically every month |
| 8 | +schedule: |
| 9 | + -cron:'0 0 1 * *' |
| 10 | + |
| 11 | +jobs: |
| 12 | +link_checker: |
| 13 | +name:Check links and create an automated issue, if needed |
| 14 | +runs-on:ubuntu-latest |
| 15 | +timeout-minutes:10 |
| 16 | +env: |
| 17 | +REPORT_FILE:links-report |
| 18 | +steps: |
| 19 | +## Check out code using Git |
| 20 | + -uses:actions/checkout@v2 |
| 21 | + |
| 22 | + -name:Check all links at README.md file |
| 23 | +id:lychee |
| 24 | +uses:lycheeverse/lychee-action@v1.2.0 |
| 25 | +with: |
| 26 | +output:${{ env.REPORT_FILE }} |
| 27 | +format:markdown |
| 28 | +## Do not fail this step on broken links |
| 29 | +fail:false |
| 30 | +## Allow pages replying with 200 (OK), 204 (No Content), |
| 31 | +## 206 (Partial Content), 400 (Bad Request), 403 (Forbidden), |
| 32 | +## 500 (Internal Server Error), 502 (Bad Gateway), or 504 (Gateway Timeout) |
| 33 | +## in at most 20 seconds with HTML content. |
| 34 | +args:>- |
| 35 | + --verbose |
| 36 | + --accept 200,204,206,400,403,500,502,504 |
| 37 | + --headers "accept=text/html" |
| 38 | + --timeout 20 |
| 39 | + --max-concurrency 128 |
| 40 | + --no-progress |
| 41 | + README.md |
| 42 | +env: |
| 43 | +## Avoid rate limiting when checking github.com links |
| 44 | +GITHUB_TOKEN:${{ secrets.GITHUB_TOKEN }} |
| 45 | + |
| 46 | + -name:Lychee's exit code |
| 47 | +## https://github.com/lycheeverse/lychee#exit-codes |
| 48 | +run:echo Lychee exit with ${{ steps.lychee.outputs.exit_code }} |
| 49 | + |
| 50 | + -name:Find the last report issue open |
| 51 | +uses:micalevisk/last-issue-action@v1 |
| 52 | +id:last_issue |
| 53 | +with: |
| 54 | +state:open |
| 55 | +labels:| |
| 56 | + report |
| 57 | + automated issue |
| 58 | +env: |
| 59 | +GITHUB_TOKEN:${{ secrets.GITHUB_TOKEN }} |
| 60 | + |
| 61 | + -name:Create issue from report file |
| 62 | +if:${{ steps.last_issue.outputs.has_found == 'false' }} |
| 63 | +uses:peter-evans/create-issue-from-file@v3 |
| 64 | +with: |
| 65 | +title:Link checker report |
| 66 | +content-filepath:${{ env.REPORT_FILE }} |
| 67 | +issue-number:${{ steps.last_issue.outputs.issue_number }} |
| 68 | +labels:| |
| 69 | + report |
| 70 | + automated issue |
| 71 | +
|
| 72 | + -name:Update last report open issue created |
| 73 | +if:${{ steps.last_issue.outputs.has_found == 'true' }} |
| 74 | +uses:peter-evans/create-issue-from-file@v3 |
| 75 | +with: |
| 76 | +title:Link checker report |
| 77 | +content-filepath:${{ env.REPORT_FILE }} |
| 78 | +issue-number:${{ steps.last_issue.outputs.issue_number }} |
| 79 | +labels:| |
| 80 | + report |
| 81 | + automated issue |
| 82 | +
|
| 83 | + -name:Close last report open issue |
| 84 | +if:${{ steps.lychee.outputs.exit_code == 0 }} |
| 85 | +uses:peter-evans/close-issue@v1 |
| 86 | +with: |
| 87 | +issue-number:${{ steps.last_issue.outputs.issue_number }} |