-
Notifications
You must be signed in to change notification settings - Fork 327
271 lines (256 loc) · 9.43 KB
/
generate-screenshots.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
name: "@Desktop • Generate Screenshots"
run-name: "@Desktop • Generate Screenshots triggered by ${{ inputs.login }} ${{ inputs.ref && format('on branch {0}', inputs.ref) || format('on PR {0}', inputs.number) }}"
on:
workflow_dispatch:
inputs:
ref:
description: The branch to generate screenshots for.
required: false
number:
description: The pull request number.
required: false
login:
description: The GitHub username that triggered the workflow
required: true
commentId:
description: comment id to update
required: false
concurrency:
# See: https://github.com/orgs/community/discussions/35341
group: ${{ github.workflow }}-${{ github.event.inputs.ref || github.event.inputs.number }}
cancel-in-progress: true
jobs:
generate-screenshots-linux:
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
runs-on: [ledger-live-4xlarge-linux]
steps:
- name: generate token
id: generate-token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.GH_BOT_APP_ID }}
private_key: ${{ secrets.GH_BOT_PRIVATE_KEY }}
- uses: actions/checkout@v3
if: ${{ inputs.ref != null }}
with:
ref: ${{ inputs.ref }}
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}
- uses: actions/checkout@v3
if: ${{ !inputs.ref }}
with:
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}
- name: Install gh
run: |
type -p curl >/dev/null || sudo apt install curl -y
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg \
&& sudo chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg \
&& echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null \
&& sudo apt update \
&& sudo apt install gh -y
- name: Checkout PR
if: ${{ inputs.number != null && inputs.ref == null }}
run: gh pr checkout ${{ inputs.number }}
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- name: set git user
run: |
git config user.email "105061298+live-github-bot[bot]@users.noreply.github.com"
git config user.name "live-github-bot[bot]"
- uses: ./tools/actions/composites/setup-test-desktop
id: setup-test-desktop
with:
skip_ruby: true
install_playwright: true
aws-access-key: ${{ secrets.AWS_S3_CACHE_ACCESS_KEY }}
aws-secret-key: ${{ secrets.AWS_S3_CACHE_SECRET_KEY }}
- uses: ./tools/actions/composites/update-snapshots-desktop
id: update-snapshots
with:
os: ubuntu-latest
# REWORK WINDOWS FOR OWN RUNNERS ? WAITING FOR KUBERNETES SOLUTION FROM INFRA ?
generate-screenshots-windows:
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
runs-on: [ledger-live-4xlarge-windows-2022]
steps:
- name: generate token
id: generate-token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.GH_BOT_APP_ID }}
private_key: ${{ secrets.GH_BOT_PRIVATE_KEY }}
- uses: actions/checkout@v3
if: ${{ inputs.ref != null }}
with:
ref: ${{ inputs.ref }}
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}
- uses: actions/checkout@v3
if: ${{ !inputs.ref }}
with:
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}
- name: Checkout PR
if: ${{ inputs.number != null && inputs.ref == null }}
run: gh pr checkout ${{ inputs.number }}
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- uses: ./tools/actions/composites/setup-test-desktop
id: setup-test-desktop
with:
skip_python: true
skip_ruby: true
install_playwright: true
upgrade_npm: true
aws-access-key: ${{ secrets.AWS_S3_CACHE_ACCESS_KEY }}
aws-secret-key: ${{ secrets.AWS_S3_CACHE_SECRET_KEY }}
- name: set git user
run: |
git config user.email "105061298+live-github-bot[bot]@users.noreply.github.com"
git config user.name "live-github-bot[bot]"
- uses: ./tools/actions/composites/update-snapshots-desktop
id: update-snapshots
with:
os: windows-latest
generate-screenshots-mac:
env:
NODE_OPTIONS: "--max-old-space-size=7168"
FORCE_COLOR: 3
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: 1
runs-on: [m1, ARM64]
steps:
- name: generate token
id: generate-token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.GH_BOT_APP_ID }}
private_key: ${{ secrets.GH_BOT_PRIVATE_KEY }}
- uses: actions/checkout@v3
if: ${{ inputs.ref != null }}
with:
ref: ${{ inputs.ref }}
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}
- uses: actions/checkout@v3
if: ${{ !inputs.ref }}
with:
fetch-depth: 0
token: ${{ steps.generate-token.outputs.token }}
- name: Checkout PR
if: ${{ inputs.number != null && inputs.ref == null }}
run: gh pr checkout ${{ inputs.number }}
env:
GITHUB_TOKEN: ${{ steps.generate-token.outputs.token }}
- uses: ./tools/actions/composites/setup-test-desktop
id: setup-test-desktop
with:
skip_python: true
skip_ruby: true
install_playwright: true
pnpm_dest: ${{ runner.temp }}/setup-pnpm
aws-access-key: ${{ secrets.AWS_S3_CACHE_ACCESS_KEY }}
aws-secret-key: ${{ secrets.AWS_S3_CACHE_SECRET_KEY }}
- name: set git user
run: |
git config user.email "105061298+live-github-bot[bot]@users.noreply.github.com"
git config user.name "live-github-bot[bot]"
- uses: ./tools/actions/composites/update-snapshots-desktop
id: update-snapshots
with:
os: macos-latest
report-start:
name: Report start
runs-on: ubuntu-latest
if: inputs.commentId != ''
steps:
- name: generate token
id: generate-token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.GH_BOT_APP_ID }}
private_key: ${{ secrets.GH_BOT_PRIVATE_KEY }}
- name: report start
uses: actions/github-script@v6
with:
github-token: ${{ steps.generate-token.outputs.token }}
result-encoding: string
retries: 3
script: |
const {repo: {owner, repo}, run_id} = context
const issue_number = ${{ inputs.number }}
const body = `\
@${{ inputs.login }}
[Generating screenshots: workflow started](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
`
await github.rest.issues.updateComment({
owner,
repo,
comment_id: "${{ inputs.commentId }}",
body,
});
report-end:
needs:
[
"generate-screenshots-linux",
"generate-screenshots-windows",
"generate-screenshots-mac",
"report-start",
]
if: always()
name: Report end
runs-on: "ubuntu-latest"
steps:
- name: generate token
id: generate-token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.GH_BOT_APP_ID }}
private_key: ${{ secrets.GH_BOT_PRIVATE_KEY }}
- name: report jobs status
uses: actions/github-script@v6
with:
github-token: ${{ steps.generate-token.outputs.token }}
result-encoding: string
retries: 3
script: |
const fs = require("fs");
const {repo: {owner, repo}} = context;
const {data: {jobs}} = await github.rest.actions.listJobsForWorkflowRun({
owner,
repo,
run_id: ${{ github.run_id }},
});
const jobsStatusString = jobs
.filter(job => job.name.startsWith("generate-screenshots"))
.map(job => `${job.conclusion === "success" ? "✅" : "❌"} - [${job.name}](${job.html_url})`)
.join("\n")
const body = `\
@${{ inputs.login }}
[Generating screenshots: workflow ended](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})
**Jobs status:**
${jobsStatusString}
`
const output = {
summary: body,
};
fs.writeFileSync("summary.json", JSON.stringify(output), "utf-8");
if(${{ inputs.commentId != '' }}) {
await github.rest.issues.updateComment({
owner,
repo,
comment_id: "${{ inputs.commentId }}",
body
});
}
- uses: actions/upload-artifact@v3
name: upload summary
with:
name: summary.json
path: ${{ github.workspace }}/summary.json