-
Notifications
You must be signed in to change notification settings - Fork 15
312 lines (274 loc) · 12.8 KB
/
ci.yaml
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
name: CI
on:
workflow_dispatch:
pull_request:
branches:
- master # triggers the flow for every PR to master
- "feature/**" # triggers the flow for a PR to a branch like feature/v9
types:
- synchronize # PR was updated
- opened # PR was open
- reopened # PR was closed and is now open again
- ready_for_review # PR was converted from draft to open
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
build-docker-image:
if: ${{ github.event.pull_request.head.ref != 'changeset-release/master' }}
name: Build Picasso docker image
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
actions: write
issues: write
pull-requests: write
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v4
- name: GSM Secrets
id: secrets_manager
uses: toptal/davinci-github-actions/gsm-secrets@v15.3.1
with:
workload_identity_provider: ${{ secrets.IDENTITY_POOL }}
service_account: ${{ secrets.SA_IDENTITY_POOL }}
secrets_name: |-
DOCKER_BUILDX_ENDPOINT:toptal-ci/DOCKER_BUILDX_ENDPOINT
GCR_ACCOUNT_KEY:toptal-ci/GCR_ACCOUNT_KEY
HAPPO_API_KEY:toptal-ci/PICASSO_HAPPO_API_KEY
HAPPO_API_SECRET:toptal-ci/PICASSO_HAPPO_API_SECRET
NPM_TOKEN:toptal-ci/NPM_TOKEN
TOPTAL_BUILD_BOT_SSH_KEY:toptal-ci/TOPTAL_BUILD_BOT_SSH_KEY
TOPTAL_DEFAULT_REGISTRY:toptal-ci/TOPTAL_DEFAULT_REGISTRY
TOPTAL_DEVBOT_TOKEN:toptal-ci/TOPTAL_DEVBOT_TOKEN
TOPTAL_TRIGGERBOT_BUILD_TOKEN:toptal-ci/TOPTAL_TRIGGERBOT_BUILD_TOKEN
TOPTAL_TRIGGERBOT_USERNAME:toptal-ci/TOPTAL_TRIGGERBOT_USERNAME
- name: Parse secrets
id: parse_secrets
uses: toptal/davinci-github-actions/expose-json-outputs@v15.3.1
with:
json: ${{ steps.secrets_manager.outputs.secrets }}
- name: Set ENV Variables
run: |-
echo "DOCKER_BUILDX_ENDPOINT=${{ steps.parse_secrets.outputs.DOCKER_BUILDX_ENDPOINT }}" >> $GITHUB_ENV
echo 'GCR_ACCOUNT_KEY<<EOF' >> $GITHUB_ENV
echo '${{ steps.parse_secrets.outputs.GCR_ACCOUNT_KEY }}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
echo "GITHUB_TOKEN=${{ steps.parse_secrets.outputs.TOPTAL_DEVBOT_TOKEN }}" >> $GITHUB_ENV
echo "HAPPO_API_KEY=${{ steps.parse_secrets.outputs.HAPPO_API_KEY }}" >> $GITHUB_ENV
echo "HAPPO_API_SECRET=${{ steps.parse_secrets.outputs.HAPPO_API_SECRET }}" >> $GITHUB_ENV
echo "JENKINS_USER=${{ steps.parse_secrets.outputs.TOPTAL_TRIGGERBOT_USERNAME }}" >> $GITHUB_ENV
echo "JENKINS_BUILD_TOKEN=${{ steps.parse_secrets.outputs.TOPTAL_TRIGGERBOT_BUILD_TOKEN }}" >> $GITHUB_ENV
echo "NPM_TOKEN=${{ steps.parse_secrets.outputs.NPM_TOKEN }}" >> $GITHUB_ENV
echo 'TOPTAL_BUILD_BOT_SSH_KEY<<EOF' >> $GITHUB_ENV
echo '${{ steps.parse_secrets.outputs.TOPTAL_BUILD_BOT_SSH_KEY }}' >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
echo "TOPTAL_DEVBOT_TOKEN=${{ steps.parse_secrets.outputs.TOPTAL_DEVBOT_TOKEN }}" >> $GITHUB_ENV
- uses: toptal/davinci-github-actions/build-push-image@v15.3.1
with:
sha: ${{ github.event.pull_request.head.sha }}
image-name: picasso
environment: temploy
registry-name: ${{ steps.parse_secrets.outputs.TOPTAL_DEFAULT_REGISTRY }}
static-checks:
if: ${{ github.event.pull_request.head.ref != 'changeset-release/master' }}
name: Static checks
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
timeout-minutes: 45
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: GSM Secrets
id: secrets_manager
uses: toptal/davinci-github-actions/gsm-secrets@v15.3.1
with:
workload_identity_provider: ${{ secrets.IDENTITY_POOL }}
service_account: ${{ secrets.SA_IDENTITY_POOL }}
secrets_name: |-
HAPPO_API_KEY:toptal-ci/PICASSO_HAPPO_API_KEY
HAPPO_API_SECRET:toptal-ci/PICASSO_HAPPO_API_SECRET
NPM_TOKEN:toptal-ci/NPM_TOKEN
TOPTAL_DEVBOT_TOKEN:toptal-ci/TOPTAL_DEVBOT_TOKEN
TOPTAL_TRIGGERBOT_BUILD_TOKEN:toptal-ci/TOPTAL_TRIGGERBOT_BUILD_TOKEN
TOPTAL_TRIGGERBOT_USERNAME:toptal-ci/TOPTAL_TRIGGERBOT_USERNAME
- name: Parse secrets
id: parse_secrets
uses: toptal/davinci-github-actions/expose-json-outputs@v15.3.1
with:
json: ${{ steps.secrets_manager.outputs.secrets }}
- name: Set ENV Variables
run: |-
echo "TOPTAL_DEVBOT_TOKEN=${{ steps.parse_secrets.outputs.TOPTAL_DEVBOT_TOKEN }}" >> $GITHUB_ENV
echo "NPM_TOKEN=${{ steps.parse_secrets.outputs.NPM_TOKEN }}" >> $GITHUB_ENV
echo "HAPPO_API_KEY=${{ steps.parse_secrets.outputs.HAPPO_API_KEY }}" >> $GITHUB_ENV
echo "HAPPO_API_SECRET=${{ steps.parse_secrets.outputs.HAPPO_API_SECRET }}" >> $GITHUB_ENV
echo "JENKINS_USER=${{ steps.parse_secrets.outputs.TOPTAL_TRIGGERBOT_USERNAME }}" >> $GITHUB_ENV
echo "JENKINS_BUILD_TOKEN=${{ steps.parse_secrets.outputs.TOPTAL_TRIGGERBOT_BUILD_TOKEN }}" >> $GITHUB_ENV
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Check missing changeset
uses: toptal/davinci-github-actions/report-missing-changeset@v15.3.1
with:
github-token: ${{ env.TOPTAL_DEVBOT_TOKEN }}
# This Action will scan dependency manifest files that change as part of a Pull Request,
# surfacing known-vulnerable versions of the packages declared or updated in the PR.
# Once installed, if the workflow run is marked as required, PRs introducing known-vulnerable
# packages will be blocked from merging.
- name: Dependency Review
uses: actions/dependency-review-action@v4
- name: Install Dependencies
uses: toptal/davinci-github-actions/yarn-install@v15.3.1
- name: Update PR Body
run: node ./.github/actions/update-body.js
env:
token: ${{ env.TOPTAL_DEVBOT_TOKEN }}
- name: Syncpack check
run: yarn syncpack:list
- name: Circularity Check
run: yarn circularity
- name: Lint
run: yarn lint
- name: Type Check
run: yarn typecheck
- name: Jest Tests
run: yarn test:unit:ci
storybook-visual-tests:
if: ${{ github.event.pull_request.head.ref != 'changeset-release/master' }}
name: Storybook Visual Tests
runs-on: ubuntu-latest
permissions: write-all
needs: [static-checks]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: GSM Secrets
id: secrets_manager
uses: toptal/davinci-github-actions/gsm-secrets@v15.3.1
with:
workload_identity_provider: ${{ secrets.IDENTITY_POOL }}
service_account: ${{ secrets.SA_IDENTITY_POOL }}
secrets_name: |-
HAPPO_API_KEY:toptal-ci/PICASSO_HAPPO_API_KEY
HAPPO_API_SECRET:toptal-ci/PICASSO_HAPPO_API_SECRET
NPM_TOKEN:toptal-ci/NPM_TOKEN
TOPTAL_DEVBOT_TOKEN:toptal-ci/TOPTAL_DEVBOT_TOKEN
- name: Parse secrets
id: parse_secrets
uses: toptal/davinci-github-actions/expose-json-outputs@v15.3.1
with:
json: ${{ steps.secrets_manager.outputs.secrets }}
- name: Set ENV Variables
run: |-
echo "TOPTAL_DEVBOT_TOKEN=${{ steps.parse_secrets.outputs.TOPTAL_DEVBOT_TOKEN }}" >> $GITHUB_ENV
echo "NPM_TOKEN=${{ steps.parse_secrets.outputs.NPM_TOKEN }}" >> $GITHUB_ENV
echo "HAPPO_API_KEY=${{ steps.parse_secrets.outputs.HAPPO_API_KEY }}" >> $GITHUB_ENV
echo "HAPPO_API_SECRET=${{ steps.parse_secrets.outputs.HAPPO_API_SECRET }}" >> $GITHUB_ENV
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies from cache
uses: toptal/davinci-github-actions/yarn-install@v15.3.1
- name: Visual Tests
run: yarn happo:storybook
env:
HAPPO_PROJECT: Picasso/Storybook
HAPPO_API_KEY: ${{ env.HAPPO_API_KEY }}
HAPPO_API_SECRET: ${{ env.HAPPO_API_SECRET }}
integration-tests:
name: Integration Tests
uses: ./.github/workflows/davinci-integration-tests.yml
secrets:
IDENTITY_POOL: ${{ secrets.IDENTITY_POOL }}
SA_IDENTITY_POOL: ${{ secrets.SA_IDENTITY_POOL }}
deploy-docs:
if: ${{ github.event.pull_request.head.ref != 'changeset-release/master' }}
name: Deploy Picasso docs
runs-on: ubuntu-latest
permissions:
contents: write
id-token: write
needs: [build-docker-image]
steps:
- name: GSM Secrets
id: secrets_manager
uses: toptal/davinci-github-actions/gsm-secrets@v15.3.1
with:
workload_identity_provider: ${{ secrets.IDENTITY_POOL }}
service_account: ${{ secrets.SA_IDENTITY_POOL }}
secrets_name: |-
HAPPO_API_KEY:toptal-ci/PICASSO_HAPPO_API_KEY
HAPPO_API_SECRET:toptal-ci/PICASSO_HAPPO_API_SECRET
NPM_TOKEN:toptal-ci/NPM_TOKEN
TOPTAL_DEVBOT_TOKEN:toptal-ci/TOPTAL_DEVBOT_TOKEN
TOPTAL_TRIGGERBOT_BUILD_TOKEN:toptal-ci/TOPTAL_TRIGGERBOT_BUILD_TOKEN
TOPTAL_TRIGGERBOT_USERNAME:toptal-ci/TOPTAL_TRIGGERBOT_USERNAME
JENKINS_BUILD_URL:toptal-ci/JENKINS_BUILD_URL
JENKINS_BUILD_CLIENT_ID:toptal-ci/JENKINS_BUILD_CLIENT_ID
JENKINS_SA_CREDENTIALS:toptal-ci/JENKINS_SA_CREDENTIALS
TOPTAL_REPOACCESSBOT_TOKEN:toptal-ci/TOPTAL_REPOACCESSBOT_TOKEN
- name: Parse secrets
id: parse_secrets
uses: toptal/davinci-github-actions/expose-json-outputs@v15.3.1
with:
json: ${{ steps.secrets_manager.outputs.secrets }}
- name: Set ENV Variables
run: |-
echo "TOPTAL_DEVBOT_TOKEN=${{ steps.parse_secrets.outputs.TOPTAL_DEVBOT_TOKEN }}" >> $GITHUB_ENV
echo "NPM_TOKEN=${{ steps.parse_secrets.outputs.NPM_TOKEN }}" >> $GITHUB_ENV
echo "HAPPO_API_KEY=${{ steps.parse_secrets.outputs.HAPPO_API_KEY }}" >> $GITHUB_ENV
echo "HAPPO_API_SECRET=${{ steps.parse_secrets.outputs.HAPPO_API_SECRET }}" >> $GITHUB_ENV
echo "JENKINS_USER=${{ steps.parse_secrets.outputs.TOPTAL_TRIGGERBOT_USERNAME }}" >> $GITHUB_ENV
echo "JENKINS_BUILD_TOKEN=${{ steps.parse_secrets.outputs.TOPTAL_TRIGGERBOT_BUILD_TOKEN }}" >> $GITHUB_ENV
- name: Get toptal/actions
uses: actions/checkout@v4
with:
repository: toptal/actions
token: ${{ steps.parse_secrets.outputs.TOPTAL_REPOACCESSBOT_TOKEN }}
path: ./.github/actions/
- name: Replace toptal/actions/get-job-url@main from trigger-jenkins-job/action.yml
shell: bash
run: |
sed -i 's|toptal/actions/get-job-url@main|./.github/actions/get-job-url|' ./.github/actions/trigger-jenkins-job/action.yml
sed -i 's|toptal/actions/trigger-jenkins-job@main|./.github/actions/trigger-jenkins-job|' ./.github/actions/create-jira-deployment/action.yml
- name: Trigger doc deployment job
uses: ./.github/actions/trigger-jenkins-job/
env:
BRANCH: ${{ github.event.pull_request.head.ref }}
PR_ID: ${{ github.event.pull_request.number }}
with:
jenkins_url: ${{ steps.parse_secrets.outputs.JENKINS_BUILD_URL }}
jenkins_user: ${{ steps.parse_secrets.outputs.TOPTAL_TRIGGERBOT_USERNAME }}
jenkins_token: ${{ steps.parse_secrets.outputs.TOPTAL_TRIGGERBOT_BUILD_TOKEN }}
jenkins_client_id: ${{ steps.parse_secrets.outputs.JENKINS_BUILD_CLIENT_ID }}
jenkins_sa_credentials: ${{ steps.parse_secrets.outputs.JENKINS_SA_CREDENTIALS }}
job_name: picasso-docs
job_params: |
{
"BRANCH": "${{ env.BRANCH }}",
"PR_ID": "${{ env.PR_ID }}"
}
job_timeout: "3600"
- name: Create Jira Deployment
uses: ./.github/actions/create-jira-deployment/
if: ${{ always() }}
with:
jenkins_url: ${{ steps.parse_secrets.outputs.JENKINS_BUILD_URL }}
jenkins_user: ${{ steps.parse_secrets.outputs.TOPTAL_TRIGGERBOT_USERNAME }}
jenkins_token: ${{ steps.parse_secrets.outputs.TOPTAL_TRIGGERBOT_BUILD_TOKEN }}
jenkins_client_id: ${{ steps.parse_secrets.outputs.JENKINS_BUILD_CLIENT_ID }}
jenkins_sa_credentials: ${{ steps.parse_secrets.outputs.JENKINS_SA_CREDENTIALS }}
token: ${{ env.TOPTAL_DEVBOT_TOKEN }}
environment: staging
environment-url: ${{ steps.temploy.outputs.temployURL }}
transient-environment: false
auto-inactive: false