check-urls.yml 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. name: Check URLs from changed files
  2. on:
  3. push:
  4. pull_request:
  5. permissions:
  6. # needed for checkout code
  7. contents: read
  8. # This allows a subsequently queued workflow run to interrupt/wait for previous runs
  9. concurrency:
  10. group: '${{ github.workflow }} @ ${{ github.run_id }}'
  11. cancel-in-progress: false # true = interrupt, false = wait
  12. jobs:
  13. # NOTE: tj-actions/changed-files.
  14. # For push events you need to include fetch-depth: 0 | 2 depending on your use case.
  15. # 0: retrieve all history for all branches and tags
  16. # 1: retrieve only current commit (by default)
  17. # 2: retrieve until the preceding commit
  18. get-changed-files:
  19. name: Get changed files
  20. runs-on: ubuntu-latest
  21. outputs:
  22. fetch-depth: ${{ steps.set-params.outputs.fetch-depth }}
  23. files: ${{ steps.set-files.outputs.files }}
  24. files-len: ${{ steps.set-files.outputs.files-len }}
  25. matrix: ${{ steps.set-matrix.outputs.matrix }}
  26. steps:
  27. - name: Determine workflow params
  28. id: set-params
  29. run: |
  30. echo "fetch_depth=0" >> $GITHUB_OUTPUT
  31. if [ "${{ github.event_name }}" == "pull_request" ]; then
  32. echo "fetch_depth=0" >> $GITHUB_OUTPUT
  33. fi
  34. - name: Checkout
  35. uses: actions/checkout@v4
  36. with:
  37. fetch-depth: ${{ steps.set-params.outputs.fetch-depth }}
  38. - name: Get changed files
  39. id: changed-files
  40. uses: tj-actions/changed-files@v43.0.0
  41. with:
  42. separator: " "
  43. json: true
  44. - id: set-files
  45. run: |
  46. echo "${{ steps.changed-files.outputs.all_changed_files }}" \
  47. | jq --raw-output '. | join(" ")' \
  48. | sed -e 's/^/files=/' \
  49. >> $GITHUB_OUTPUT
  50. echo "${{ steps.changed-files.outputs.all_changed_files }}" \
  51. | jq --raw-output '. | length' \
  52. | sed -e 's/^/files-len=/' \
  53. >> $GITHUB_OUTPUT
  54. - id: set-matrix
  55. run: |
  56. echo "{\"file\":${{ steps.changed-files.outputs.all_changed_files }}}" \
  57. | sed -e 's/^/matrix=/' \
  58. >> $GITHUB_OUTPUT
  59. check-urls:
  60. name: Check @ ${{ matrix.file }}
  61. if: ${{ fromJSON(needs.get-changed-files.outputs.files-len) > 0 }}
  62. needs: [get-changed-files]
  63. runs-on: ubuntu-latest
  64. strategy:
  65. matrix: ${{ fromJSON(needs.get-changed-files.outputs.matrix) }}
  66. max-parallel: 10
  67. fail-fast: false
  68. steps:
  69. - name: Checkout
  70. uses: actions/checkout@v4
  71. with:
  72. fetch-depth: ${{ needs.get-changed-files.outputs.fetch-depth }}
  73. - name: Setup Ruby v2.6
  74. uses: ruby/setup-ruby@v1
  75. with:
  76. ruby-version: 2.6
  77. - name: Install awesome_bot
  78. run: |
  79. gem install awesome_bot
  80. - name: Set output
  81. id: set-output
  82. run: echo "FILENAME=$(echo ${{ matrix.file }} | grep -oE '[a-zA-Z0-9_-]+(\.yml|\.md)')" >> "$GITHUB_OUTPUT"
  83. - name: "Check URLs of file: ${{ matrix.file }}"
  84. run: |
  85. awesome_bot "${{ matrix.file }}" --allow-redirect --allow-dupe --allow-ssl || true;
  86. - uses: actions/upload-artifact@v4
  87. with:
  88. name: ${{ steps.set-output.outputs.FILENAME}}
  89. path: ${{ github.workspace }}/ab-results-*.json
  90. reporter:
  91. name: GitHub report
  92. needs: [get-changed-files, check-urls]
  93. runs-on: ubuntu-latest
  94. steps:
  95. - name: Checkout # for having the sources of the local action
  96. uses: actions/checkout@v4
  97. # download and unzip the ab-results-*.json generated by job-matrix: check-urls
  98. - uses: actions/download-artifact@v4
  99. with:
  100. name: ${{ steps.set-output.outputs.FILENAME}}
  101. - name: Generate Summary Report
  102. uses: ./.github/actions/awesomebot-gh-summary-action
  103. with:
  104. ab-root: ${{ github.workspace }}
  105. files: ${{ needs.get-changed-files.outputs.files }}
  106. separator: " "
  107. append-heading: ${{ true }}