-
Notifications
You must be signed in to change notification settings - Fork 20
210 lines (171 loc) · 7.51 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
name: PR Documentation and Storybook
on:
pull_request:
branches:
- dev
- master
concurrency:
# New commit on branch cancels running workflows of the same branch
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true
jobs:
scope:
uses: ./.github/workflows/change-detection.yml
with:
as-enumeration: true
secrets: inherit
build:
name: Build
needs: 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@v3
- 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: 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) }}
with:
github-token: ${{secrets.GH_TOKEN}}
script: |
const { HAS_PLASMA_B2C, HAS_PLASMA_WEB, HAS_PLASMA_UI, HAS_PLASMA_TEMPLE } = 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/`)
}
github.rest.issues.createComment({
issue_number: number,
owner,
repo,
body: `Documentation preview deployed!
${links.join('\n')}
`
});