-
Notifications
You must be signed in to change notification settings - Fork 20
274 lines (224 loc) · 10.7 KB
/
documentation-pr.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
272
273
274
name: PR Documentation and Storybook [PR into DEV branch]
on:
pull_request_target:
branches:
- dev
concurrency:
# New commit on branch cancels running workflows of the same branch
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
authorize:
name: Authorize external pull request
uses: ./.github/workflows/authorize-external-pr.yml
scope:
needs: [ authorize ]
uses: ./.github/workflows/change-detection.yml
with:
as-enumeration: true
ref: refs/pull/${{github.event.pull_request.number}}/merge
secrets: inherit
build:
name: Build
needs: [ authorize, scope ]
if: ${{ needs.scope.outputs.HAS_DOCUMENTATION_CHANGED == 'true' }}
runs-on: ubuntu-latest
env:
NPM_REGISTRY_TOKEN: ${{ secrets.NPM_REGISTRY_TOKEN }}
PR_NAME: pr-${{ github.event.number }}
ICONS_PUBLIC_URL: /icons
steps:
- uses: actions/checkout@v4
with:
show-progress: false
ref: refs/pull/${{github.event.pull_request.number}}/merge
- name: Prepare environment
uses: ./.github/actions/prepare-environment
- name: Computed scope
id: scope
uses: actions/github-script@v6
env:
ENUMERATION: ${{ toJSON(needs.scope.outputs.PACKAGES_ENUMERATION) }}
with:
result-encoding: string
script: |
const { ENUMERATION } = process.env;
const enumeration = JSON.parse(JSON.parse(ENUMERATION));
if (!enumeration.includes('plasma-core')) {
enumeration.push('plasma-core');
}
if (!enumeration.includes('plasma-hope')) {
enumeration.push('plasma-hope');
}
if (!enumeration.includes('plasma-new-hope')) {
enumeration.push('plasma-new-hope');
}
if (!enumeration.includes('plasma-tokens-utils')) {
enumeration.push('plasma-tokens-utils');
}
if (enumeration.includes('plasma-tokens-native') && !enumeration.includes('plasma-tokens')) {
enumeration.push('plasma-tokens');
}
if (!enumeration.includes('plasma-icons')) {
enumeration.push('plasma-icons');
}
if (!enumeration.includes('plasma-docs-ui')) {
enumeration.push('plasma-docs-ui');
}
if (!enumeration.includes('plasma-website')) {
enumeration.push('plasma-website');
}
if(enumeration.includes('plasma-website') && !enumeration.includes('plasma-b2c')) {
enumeration.push('plasma-b2c');
}
if (enumeration.includes('plasma-temple-docs') || enumeration.includes('plasma-ui-docs')) {
enumeration.push('plasma-web');
}
return enumeration.join(',');
- name: Lerna bootstrap
run: npx lerna bootstrap --scope=@salutejs/{${{steps.scope.outputs.result}}}
- name: Prepare directory
run: mkdir -p s3_build/${PR_NAME}
# TODO: https://github.com/salute-developers/plasma/issues/603
- name: Plasma Website
run: |
export NODE_OPTIONS=--openssl-legacy-provider
npm run build --prefix="./website/plasma-website"
cp -R ./website/plasma-website/build/. ./s3_build/${PR_NAME}
- name: Plasma UI Docs
if: ${{ needs.scope.outputs.HAS_PLASMA_UI_DOCS == 'true' && needs.scope.outputs.HAS_PLASMA_UI == 'true' }}
run: |
export NODE_OPTIONS=--openssl-legacy-provider
npm run build --prefix="./website/plasma-ui-docs"
cp -R ./website/plasma-ui-docs/build ./s3_build/${PR_NAME}/ui
- name: Plasma Web Docs
if: ${{ needs.scope.outputs.HAS_PLASMA_WEB_DOCS == 'true' }}
run: |
export NODE_OPTIONS=--openssl-legacy-provider
npm run build --prefix="./website/plasma-web-docs"
cp -R ./website/plasma-web-docs/build ./s3_build/${PR_NAME}/web
- name: Plasma Web Temple
if: ${{ needs.scope.outputs.HAS_PLASMA_TEMPLE_DOCS == 'true' && needs.scope.outputs.HAS_PLASMA_TEMPLE == 'true' }}
run: |
export NODE_OPTIONS=--openssl-legacy-provider
npm run build --prefix="./website/plasma-temple-docs"
cp -R ./website/plasma-temple-docs/build ./s3_build/${PR_NAME}/temple
- name: Plasma UI Storybook
if: ${{ needs.scope.outputs.HAS_PLASMA_UI == 'true' }}
run: |
npm run storybook:build --prefix="./packages/plasma-ui"
cp -R ./packages/plasma-ui/build-sb ./s3_build/${PR_NAME}/ui-storybook
- name: Plasma Web Storybook
if: ${{ needs.scope.outputs.HAS_PLASMA_WEB == 'true' }}
run: |
npm run storybook:build --prefix="./packages/plasma-web"
cp -R ./packages/plasma-web/build-sb ./s3_build/${PR_NAME}/web-storybook
- name: Plasma B2C Storybook
if: ${{ needs.scope.outputs.HAS_PLASMA_B2C == 'true' }}
run: |
npm run storybook:build --prefix="./packages/plasma-b2c"
cp -R ./packages/plasma-b2c/build-sb ./s3_build/${PR_NAME}/b2c-storybook
- name: Plasma Temple Storybook
if: ${{ needs.scope.outputs.HAS_PLASMA_TEMPLE == 'true' }}
run: |
npm run storybook:build --prefix="./packages/plasma-temple"
cp -R ./packages/plasma-temple/build-sb ./s3_build/${PR_NAME}/temple-storybook
- name: Plasma "New Hope" Storybook
if: ${{ needs.scope.outputs.HAS_PLASMA_HOPE == 'true' }}
run: |
npm run storybook:build --prefix="./packages/plasma-new-hope"
cp -R ./packages/plasma-new-hope/build-sb ./s3_build/${PR_NAME}/new-hope-storybook
- name: Plasma "ASDK" Storybook
if: ${{ needs.scope.outputs.HAS_PLASMA_ASDK == 'true' }}
run: |
npm run storybook:build --prefix="./packages/plasma-asdk"
cp -R ./packages/plasma-asdk/build-sb ./s3_build/${PR_NAME}/asdk-storybook
- name: Plasma "Caldera" Storybook
if: ${{ needs.scope.outputs.HAS_CALDERA == 'true' }}
run: |
npm run storybook:build --prefix="./packages/caldera"
cp -R ./packages/caldera/build-sb ./s3_build/${PR_NAME}/caldera-storybook
- name: Plasma "Caldera-online" Storybook
if: ${{ needs.scope.outputs.HAS_CALDERA_ONLINE == 'true' }}
run: |
npm run storybook:build --prefix="./packages/caldera-online"
cp -R ./packages/caldera-online/build-sb ./s3_build/${PR_NAME}/caldera-online-storybook
- name: Plasma "SDDS SRVC" Storybook
if: ${{ needs.scope.outputs.HAS_SDDS_SRVC == 'true' }}
run: |
npm run storybook:build --prefix="./packages/sdds-srvc"
cp -R ./packages/sdds-srvc/build-sb ./s3_build/${PR_NAME}/sdds-srvc-storybook
- name: Install s3cmd
run: pip3 install s3cmd
- name: s3 Upload builds
run: >
s3cmd
--access_key ${{ secrets.AWS_ACCESS_KEY_ID }}
--secret_key ${{ secrets.AWS_SECRET_ACCESS_KEY }}
--host ${{ secrets.AWS_ENDPOINT }}
--host-bucket ${{ secrets.AWS_ENDPOINT }}
--bucket-location ${{ secrets.AWS_REGION }}
--signature-v2
--delete-removed
--no-mime-magic
sync
./s3_build/${PR_NAME}/
s3://${{ secrets.AWS_S3_BUCKET_2 }}/pr/${PR_NAME}/
- name: Post success comment
uses: actions/github-script@v6
env:
HAS_PLASMA_B2C: ${{ fromJSON(needs.scope.outputs.HAS_PLASMA_B2C) }}
HAS_PLASMA_WEB: ${{ fromJSON(needs.scope.outputs.HAS_PLASMA_WEB) }}
HAS_PLASMA_UI: ${{ fromJSON(needs.scope.outputs.HAS_PLASMA_UI) }}
HAS_PLASMA_TEMPLE: ${{ fromJSON(needs.scope.outputs.HAS_PLASMA_TEMPLE) }}
HAS_PLASMA_HOPE: ${{ fromJSON(needs.scope.outputs.HAS_PLASMA_HOPE) }}
HAS_PLASMA_ASDK: ${{ fromJSON(needs.scope.outputs.HAS_PLASMA_ASDK) }}
HAS_CALDERA: ${{ fromJSON(needs.scope.outputs.HAS_CALDERA) }}
HAS_CALDERA_ONLINE: ${{ fromJSON(needs.scope.outputs.HAS_CALDERA_ONLINE) }}
HAS_SDDS_SRVC: ${{ fromJSON(needs.scope.outputs.HAS_SDDS_SRVC) }}
with:
github-token: ${{secrets.GH_TOKEN}}
script: |
const { HAS_PLASMA_B2C, HAS_PLASMA_WEB, HAS_PLASMA_UI, HAS_PLASMA_TEMPLE, HAS_PLASMA_HOPE, HAS_PLASMA_ASDK, HAS_CALDERA, HAS_CALDERA_ONLINE, HAS_SDDS_SRVC } = process.env;
const {
issue: { number },
repo: { owner, repo }
} = context;
const links = [
`website: http://plasma.sberdevices.ru/pr/pr-${number}/`
];
if (HAS_PLASMA_B2C === 'true') {
links.push(`b2c storybook: http://plasma.sberdevices.ru/pr/pr-${number}/b2c-storybook/`)
}
if (HAS_PLASMA_WEB === 'true') {
links.push(`web storybook: http://plasma.sberdevices.ru/pr/pr-${number}/web-storybook/`)
}
if (HAS_PLASMA_UI === 'true') {
links.push(`ui storybook: http://plasma.sberdevices.ru/pr/pr-${number}/ui-storybook/`)
}
if (HAS_PLASMA_TEMPLE === 'true') {
links.push(`temple storybook: http://plasma.sberdevices.ru/pr/pr-${number}/temple-storybook/`)
}
if (HAS_PLASMA_HOPE === 'true') {
links.push(`new-hope storybook: http://plasma.sberdevices.ru/pr/pr-${number}/new-hope-storybook/`)
}
if (HAS_PLASMA_ASDK === 'true') {
links.push(`asdk storybook: http://plasma.sberdevices.ru/pr/pr-${number}/asdk-storybook/`)
}
if (HAS_CALDERA === 'true') {
links.push(`caldera storybook: http://plasma.sberdevices.ru/pr/pr-${number}/caldera-storybook/`)
}
if (HAS_CALDERA_ONLINE === 'true') {
links.push(`caldera-online storybook: http://plasma.sberdevices.ru/pr/pr-${number}/caldera-online-storybook/`)
}
if (HAS_SDDS_SRVC === 'true') {
links.push(`sdds-srvc storybook: http://plasma.sberdevices.ru/pr/pr-${number}/sdds-srvc-storybook/`)
}
github.rest.issues.createComment({
issue_number: number,
owner,
repo,
body: `Documentation preview deployed!
${links.join('\n')}
`
});