-
Notifications
You must be signed in to change notification settings - Fork 2
163 lines (144 loc) · 6.12 KB
/
post_deployment_actions.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
name: Deployment Actions
on: deployment_status
env:
PUPPETEER_DOWNLOAD_PATH: /home/runner/.npm/chromium
jobs:
dump_github_event:
uses: ./.github/workflows/dump_event.yml
# Do a find-and-replace to add a link to the deployment to the PR body
update_pr_description:
# Only want to run on success, otherwise it might be "pending", or "failure".
# Filter out storybook deployments and temporarily Netlify deployments
if: ${{ (github.event.deployment.ref != 'main') && (github.event.deployment_status.state == 'success') && !startsWith(github.event.deployment_status.environment, 'storybook')}}
name: Add deploy URL to PR description
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# Note we can't use caching here, because caching needs GITHUB_REF to be defined,
# and Vercel deployment_status events set deployment.ref to the SHA, not the triggering
# branch or pull request.
# https://github.com/actions/cache/issues/319
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
- run: npm ci
- uses: ./.github/actions/ref_from_sha
name: Get PR Ref from SHA
id: ref_from_sha
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- uses: mcky/[email protected]
with:
githubToken: ${{ secrets.GITHUB_TOKEN }}
prNumber: ${{ steps.ref_from_sha.outputs.pr_number }}
find: "{owa_deployment_url}"
replace: ${{ github.event.deployment_status.environment_url }}
# Warm the caches on the test URLs
# warm_caches:
# # Only want to run on success, otherwise it might be "pending", or "failure".
# # Filter out storybook deployments and temporarily Netlify deployments
# if: ${{ (github.event.deployment_status.state == 'success') && !startsWith(github.event.deployment_status.environment, 'storybook')}}
# name: Warm Caches
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - name: Use Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 20.x
# cache: "npm"
# - run: npm ci
# - name: Warm the Cache
# run: node ./scripts/build/warm_cache.js
# env:
# BASE_URL: ${{ github.event.deployment_status.environment_url }}
# CF_ACCESS_CLIENT_ID: ${{ secrets.CF_ACCESS_CLIENT_ID }}
# CF_ACCESS_CLIENT_SECRET: ${{ secrets.CF_ACCESS_CLIENT_SECRET }}
# Run Pa11yCI against a deployment.
pa11y:
# needs: warm_caches
# Only want to run on success, otherwise it might be "pending", or "failure".
# Filter out storybook deployments and temporarily Netlify deployments
if: ${{ (github.event.deployment_status.state == 'success') && !startsWith(github.event.deployment_status.environment, 'storybook')}}
name: Pa11y
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
# Install.
- run: npm ci
- name: Log out URL
run: echo "${{ github.event.deployment_status.environment_url }}"
# Run pa11y
- name: Pa11y CI
id: run_pa11y
run: npm run pa11y
env:
BASE_URL: ${{ github.event.deployment_status.environment_url }}
CF_ACCESS_CLIENT_ID: ${{ secrets.CF_ACCESS_CLIENT_ID }}
CF_ACCESS_CLIENT_SECRET: ${{ secrets.CF_ACCESS_CLIENT_SECRET }}
# Set a custom status because there may be more than one deployment_status
# event due to alternatively themed deployments, and multiple runs of this
# workflow will overwrite each other in the PR checks UI, but custom statuses
# will remain
- uses: ./.github/actions/custom_statuses
name: Set Pa11y check result
if: ${{ always() }}
with:
description: Pa11y (${{github.event.deployment_status.environment}})
state: ${{ steps.run_pa11y.outcome }}
github_token: ${{ secrets.GITHUB_TOKEN }}
# Run Percy visual regression tests against preview and production deployments.
percy:
# needs: warm_caches
# Only want to run on success, otherwise it might be "pending", or "failure".
# Filter out storybook deployments and temporarily Netlify deployments
if: ${{ (github.event.deployment_status.state == 'success') && !startsWith(github.event.deployment_status.environment, 'storybook')}}
name: Percy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Use Node.js
uses: actions/setup-node@v4
with:
node-version: 20.x
cache: "npm"
- run: npm ci
- name: Log out URL
run: echo "${{ github.event.deployment_status.environment_url }}"
- uses: ./.github/actions/ref_from_sha
name: Get PR Ref from SHA
id: ref_from_sha
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
- name: print branch name and PR number from sha
run: |
echo "${{ steps.ref_from_sha.outputs.branch_name }}"
echo "${{ steps.ref_from_sha.outputs.pr_number }}"
- uses: ./.github/actions/percy_snapshots
name: run percy
id: run_percy
with:
base_url: ${{ github.event.deployment_status.environment_url }}
branch_name: ${{ steps.ref_from_sha.outputs.branch_name }}
pr_number: ${{ steps.ref_from_sha.outputs.pr_number }}
percy_token: ${{ secrets.PERCY_TOKEN }}
env:
CF_ACCESS_CLIENT_ID: ${{ secrets.CF_ACCESS_CLIENT_ID }}
CF_ACCESS_CLIENT_SECRET: ${{ secrets.CF_ACCESS_CLIENT_SECRET }}
PERCY_PAGE_LOAD_TIMEOUT: 60000
# Set custom status so results preserved between multiple
# deployment events from same commit
- uses: ./.github/actions/custom_statuses
name: Set Percy check result
if: ${{ always() }}
with:
description: Percy (${{github.event.deployment_status.environment}})
state: ${{ steps.run_percy.outcome }}
github_token: ${{ secrets.GITHUB_TOKEN }}