-
Notifications
You must be signed in to change notification settings - Fork 6
183 lines (152 loc) · 7.03 KB
/
broken-links-check.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
name: Broken link check (va.gov)
on:
# Manual trigger
workflow_dispatch:
# Schedule; currently once nightly, at 7:20 UTC.
schedule:
- cron: 20 7 * * *
concurrency:
group: broken-links-check
cancel-in-progress: true
env:
SLACK_CHANNEL: C06DSBT7CBW #status-next-build
TOTAL_INSTANCES: 64
jobs:
broken-links-check:
name: Broken link check
runs-on: ubuntu-latest
timeout-minutes: 60
strategy:
fail-fast: false
max-parallel: 64
matrix:
# This is awkward, but necessary. There's no shorthand.
instance_number: [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]
steps:
- name: Check out repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version-file: .nvmrc
- name: Install Npm Dependencies
run: |
yarn set version 3.6.1
HUSKY=0 yarn install --immutable
# This is necessary in order for fetch to work.
- name: Build proxy-fetcher dist
run: |
yarn tsc -b ./packages/proxy-fetcher/tsconfig.json
- name: Rebuild combined cert
run: |
yarn certs
# Runs the link check on a given instance. Each instance is passed the
# total number of instances and a particular instance. The script uses
# this to restrict the link checking to a slice.
- name: Run broken link check
run: |
TOTAL_INSTANCES=${{ env.TOTAL_INSTANCES }} INSTANCE_NUMBER=${{ matrix.instance_number }} APP_ENV=gha NODE_EXTRA_CA_CERTS=certs/VA-mozilla-combined.pem SITE_URL=https://va.gov/ node --max-old-space-size=4000 scripts/check-broken-links.js
- name: Rename broken link json
id: rename-report-file
run: |
mv broken-links-report.json "broken-links-report-run-${{github.run_id}}-instance-${{ matrix.instance_number }}.json"
- name: Upload individual report json
id: upload-report-json
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
with:
name: "broken-links-report-run-${{github.run_id}}-instance-${{ matrix.instance_number }}.json"
path: broken-links-report-run-${{github.run_id}}-instance-${{ matrix.instance_number }}.json
retention-days: 1
prepare-reports:
name: Prepare reports
needs: broken-links-check
runs-on: ubuntu-latest
outputs:
SLACK_PAYLOAD: ${{ steps.export-slack-payload.outputs.SLACK_PAYLOAD }}
steps:
- name: Check out repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11
- name: Set up node
uses: actions/setup-node@60edb5dd545a775178f52524783378180af0d1f8
with:
node-version-file: .nvmrc
- name: Install Npm Dependencies
run: |
yarn set version 3.6.1
HUSKY=0 yarn install --immutable
# This grabs all currently created artifacts i.e. individual json reports.
- name: Download link reports
uses: actions/download-artifact@c850b930e6ba138125429b7e5c93fc707a7f8427
with:
merge-multiple: true
# Combines the individual reports, creates and outputs json, md, csv.
- name: Create reports
run: |
node scripts/create-combined-reports.js
# Renames help to identify the report, avoids broken-link-report (1).json
- name: Rename report files
id: rename-report-files
run: |
mv broken-links-report-combined.json "broken-links-report-combined-run-${{github.run_id}}.json"
mv broken-links-report.md "broken-links-report-run-${{github.run_id}}.md"
mv broken-links-report.csv "broken-links-report-run-${{github.run_id}}.csv"
echo REPORT_JSON=broken-links-report-combined-run-${{github.run_id}}.json >> $GITHUB_OUTPUT
- name: Upload report json
id: upload-report-json
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
with:
name: "broken-links-report-combined-run-${{github.run_id}}.json"
path: broken-links-report-combined-run-${{github.run_id}}.json
retention-days: 30
- name: Upload report markdown
id: upload-report-markdown
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
with:
name: "broken-links-report-run-${{github.run_id}}.md"
path: broken-links-report-run-${{github.run_id}}.md
retention-days: 30
- name: Upload report CSV
id: upload-report-csv
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3
with:
name: "broken-links-report-run-${{github.run_id}}.csv"
path: broken-links-report-run-${{github.run_id}}.csv
retention-days: 30
# Takes the information above and constructs json to deliver to Slack.
- name: Prepare Slack payload
run: |
node scripts/broken-links-slack-payload.js -m ${{ steps.upload-report-markdown.outputs.artifact-url }} -i ${{ steps.rename-report-files.outputs.REPORT_JSON}} -c ${{ steps.upload-report-csv.outputs.artifact-url }}
- name: Export Slack payload
id: export-slack-payload
run: echo SLACK_PAYLOAD=$(cat broken-links-slack-payload.json) >> $GITHUB_OUTPUT
notify-success:
name: Notify Success
runs-on: ubuntu-latest
needs: prepare-reports
steps:
- name: Check out repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Notify Slack
uses: department-of-veterans-affairs/platform-release-tools-actions/slack-notify@8c496a4b0c9158d18edcd9be8722ed0f79e8c5b4 # main
continue-on-error: true
with:
payload: ${{ needs.prepare-reports.outputs.SLACK_PAYLOAD }}
channel_id: ${{ env.SLACK_CHANNEL }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
notify-failure:
name: Notify Failure
runs-on: ubuntu-latest
if: ${{ failure() || cancelled() }}
needs: prepare-reports
steps:
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Notify Slack
uses: department-of-veterans-affairs/platform-release-tools-actions/slack-notify@8c496a4b0c9158d18edcd9be8722ed0f79e8c5b4 # main
continue-on-error: true
with:
payload: '{"attachments": [{"color": "#D33834","blocks": [{"type": "section","text": {"type": "mrkdwn","text": ">:warning: The broken links check failed to complete: <https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}>"}}]}]}'
channel_id: ${{ env.SLACK_CHANNEL }}
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}