links_checker.yml 2.7 KB

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