-
Notifications
You must be signed in to change notification settings - Fork 13
103 lines (85 loc) · 3.84 KB
/
generate-test-seed.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
name: Generate Test Seed
on:
pull_request:
paths:
- 'studies/**'
jobs:
build:
runs-on: ubuntu-latest
env:
REMOTE_SEED_PATH: 'pull/${{ github.event.pull_request.number }}/seed'
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: Comment "Generation In Progress"
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const commentBody =
`## 🔄 Generating Test Seed...
A new test seed file is currently being generated for this pull request.
### What's Next?
- The generation process typically takes a few minutes.
- Once the generation is complete, this comment will provide further instructions.
`
const comment = require('.github/workflows/scripts/comment.js')
await comment(github, context, commentBody)
- name: Install
run: |
npm ci
- name: Build & Test
run: |
npm run typecheck:scripts
npm run build:proto
npm run typecheck
npm run test
- name: Lint
run: |
npm run lint -- --base origin/${{ github.event.pull_request.base.ref }}
- name: Generate seed
run: |
npm run seed_tools -- create_seed studies seed.bin
- name: Upload seed
env:
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_PRODUCTION_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_PRODUCTION_SECRET_ACCESS_KEY }}
AWS_REGION: us-west-2
CLOUDFRONT_DISTRIBUTION_ID: ${{ secrets.CLOUDFRONT_DISTRIBUTION_ID }}
run: |
gzip -c seed.bin | aws s3 cp - "s3://brave-production-griffin-origin/$REMOTE_SEED_PATH" \
--content-type application/octet-stream \
--content-encoding gzip
INVALIDATION_ID=$(aws cloudfront create-invalidation --distribution-id "$CLOUDFRONT_DISTRIBUTION_ID" --paths "/$REMOTE_SEED_PATH" --query 'Invalidation.Id' --output text)
aws cloudfront wait invalidation-completed --distribution-id "$CLOUDFRONT_DISTRIBUTION_ID" --id "$INVALIDATION_ID"
- name: Comment "Generation Successful"
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
const fs = require('fs');
const variationsServerURL = `https://griffin.brave.com/${process.env.REMOTE_SEED_PATH}`;
const serialNumberContent = fs.readFileSync('serialnumber', 'utf8');
const commentBody =
`## 🚀 Test Seed Generated
To test the new seed, launch the browser with the following command line:
\`\`\`
--accept-empty-variations-seed-signature --variations-server-url=${variationsServerURL}
\`\`\`
#### Seed Details
- Serial Number: \`${serialNumberContent}\`
- Uploaded: \`${new Date().toISOString()}\`
`
const comment = require('.github/workflows/scripts/comment.js')
await comment(github, context, commentBody)
- name: Comment "Generation Failed"
if: failure()
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
with:
script: |
console.log(process.env)
console.log(context)
const actionRunURL = `${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/jobs/${process.env.GITHUB_JOB}`;
const commentBody =
`## ❌ Test Seed Generation Failed
[Review the workflow logs for more information.](${actionRunURL})
`
const comment = require('.github/workflows/scripts/comment.js')
await comment(github, context, commentBody)