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