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