links_checker.yml 2.6 KB

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