-
Notifications
You must be signed in to change notification settings - Fork 6
307 lines (261 loc) · 8.14 KB
/
checkout-test-build-deploy.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
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
name: Build and deploy
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
on:
workflow_dispatch:
inputs:
source:
description: 'Source of event'
required: false
default: 'No source specified'
push:
branches:
- main
pull_request:
branches:
- main
jobs:
embed-docs:
name: Embed docs
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare
uses: ./.github/actions/checkout-install
# @T00D00 - "pnpm run build" fails with symlinks
- name: Clone sub-docs
env:
GITLAB_FRONTENDS_USERNAME: ${{ secrets.GITLAB_FRONTENDS_USERNAME }}
GITLAB_FRONTENDS_ACCESS_KEY: ${{ secrets.GITLAB_FRONTENDS_ACCESS_KEY }}
FIGMA_TOKEN: ${{ secrets.FIGMA_TOKEN }}
FIGMA_FILE: ${{ secrets.FIGMA_FILE }}
run: |
chmod +x ./.github/scripts/embed.sh
.github/scripts/embed.sh
ls -la ../..
ls -la ..
ls -la .
ls -la ./src
ls -la ./src/resources
- name: Zip folder
run: |
zip -r embed.zip ./src/ -x \*/node_modules/\* -x \*/.vitepress/\*
cd src && zip -r db-index.zip * -i '*.md' -x '*/node_modules/*' -x '*/_source/*'
- name: Upload build
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: embed-${{ github.sha }}
path: embed.zip
- name: Upload DB index
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: db-index-${{ github.sha }}
path: src/db-index.zip
test-dev:
name: Test dev
runs-on: ubuntu-latest
timeout-minutes: 10
needs: embed-docs
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare
uses: ./.github/actions/checkout-install
with:
apt: true
- uses: actions/download-artifact@v3
with:
name: embed-${{ github.sha }}
- name: Unzip artifact
run: |
unzip -o embed.zip
- name: Test
run: |
export NODE_OPTIONS="--max-old-space-size=8096"
pnpm run test
build:
name: Build
runs-on: ubuntu-latest
timeout-minutes: 60
needs: embed-docs
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare
uses: ./.github/actions/checkout-install
with:
apt: true
- uses: actions/download-artifact@v3
with:
name: embed-${{ github.sha }}
- name: Unzip artifact
run: |
unzip -o embed.zip
- name: Collect Workflow Telemetry
uses: runforesight/workflow-telemetry-action@v1
- name: Build project
run: |
export NODE_OPTIONS="--max-old-space-size=8096"
export USERCENTRICS="65ynhGFvE"
pnpm run build
#- name: Zip externals
# run: |
# cd external && zip -r db-external.zip * -i '*.md'
- name: Zip folder
run: zip -r full-build.zip .vitepress/dist/ vercel.json
- name: Upload build
uses: actions/upload-artifact@v3
with:
if-no-files-found: error
name: full-build-${{ github.sha }}
path: full-build.zip
#- name: Upload external
# uses: actions/upload-artifact@v3
# with:
# if-no-files-found: error
# name: db-external-${{ github.sha }}
# path: external/db-external.zip
test-build:
name: Test build
runs-on: ubuntu-latest
timeout-minutes: 60
needs:
- embed-docs
- build
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Prepare
uses: ./.github/actions/checkout-install
with:
apt: true
- uses: actions/download-artifact@v3
with:
name: embed-${{ github.sha }}
- uses: actions/download-artifact@v3
with:
name: full-build-${{ github.sha }}
- name: Unzip artifact
run: |
unzip -o embed.zip
- name: Unzip artifact
run: |
mkdir -p .vitepress/dist
unzip -o full-build.zip
ls -la .vitepress/dist
- name: Test
run: |
export NODE_OPTIONS="--max-old-space-size=8096"
pnpm run test:build
# chromatic:
# name: Deploy Storybook to Chromatic
# runs-on: ubuntu-latest
# timeout-minutes: 10
# needs:
# - test-cli
# - test-dev
# - test-build
# - build
# if: ${{ github.ref == 'refs/heads/main' || contains(github.event.head_commit.message, 'chromatic') }}
# steps:
# - name: Checkout repository
# uses: actions/checkout@v3
# with:
# fetch-depth: 0
#
# - name: Prepare
# uses: ./.github/actions/checkout-install
#
# - name: Deploy Storybook to Chromatic
# env:
# CHROMATIC_PROJECT_TOKEN: ${{ secrets.CHROMATIC_PROJECT_TOKEN }}
# run: pnpm chromatic
deploy-vercel:
name: Deploy to Vercel
runs-on: ubuntu-latest
timeout-minutes: 15
needs:
- test-dev
- test-build
- build
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/download-artifact@v3
with:
name: full-build-${{ github.sha }}
- name: Unzip artifact
run: |
mkdir -p .vitepress/dist
unzip -o full-build.zip
ls -la .vitepress/dist
- name: Install Vercel CLI
run: npm install -g vercel@latest
- name: Pull Vercel Environment Information
run: |
VERCEL_ENV="preview"
VERCEL_ENV_FLAG=""
if [[ "${{github.ref}}" == "refs/heads/main" ]]; then
VERCEL_ENV="production"
VERCEL_ENV_FLAG="--prod"
fi
vercel pull --yes --environment=$VERCEL_ENV --token=${{ secrets.VERCEL_TOKEN }} --scope=${{ secrets.VERCEL_ORG_ID }}
vercel build ./.vitepress/dist --token=${{ secrets.VERCEL_TOKEN }} $VERCEL_ENV_FLAG
vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} $VERCEL_ENV_FLAG > ./vercel.env
rebuild-index:
name: Send documents
runs-on: ubuntu-latest
timeout-minutes: 5
needs:
- embed-docs
- deploy-vercel
steps:
- uses: actions/download-artifact@v3
with:
name: db-index-${{ github.sha }}
#- uses: actions/download-artifact@v3
# with:
# name: db-external-${{ github.sha }}
- name: Merge base and external sources
run: |
mkdir merged
unzip -o db-index.zip -d merged
true || unzip -o db-external.zip -d merged
cd merged; zip -r ../db-merged.zip *
- name: Send artifact
env:
KNOWLEDGE_URL: ${{ secrets.KNOWLEDGE_URL }}
KNOWLEDGE_API_KEY: ${{ secrets.KNOWLEDGE_API_KEY }}
run: |
COLLECTION_PARAM=""
COLLECTION=""
if [[ "${GITHUB_REF##*/}" != "refs/heads/main" ]]; then
BRANCH=$(echo "${GITHUB_REF##*/}" | sed 's/refs\/heads\///' | tr '[:upper:]' '[:lower:]' | tr '/' '_')
COLLECTION="shopware--developer-portal--$BRANCH"
COLLECTION_PARAM="-F collection=\"${COLLECTION}\""
fi
echo "Collection: ${COLLECTION}"
echo "Uploading documents"
curl -v \
--fail-with-body \
-F [email protected] $COLLECTION_PARAM \
-H "X-Shopware-Api-Key: $KNOWLEDGE_API_KEY" \
"${KNOWLEDGE_URL}/upload-input"
echo "Ingesting documents"
curl \
--fail-with-body \
-X POST \
--data "{\"collection\":\"${COLLECTION}\"}" \
-H "Content-Type: application/json" \
-H "X-Shopware-Api-Key: $KNOWLEDGE_API_KEY" \
"${KNOWLEDGE_URL}/ingest"
echo "Documents ingested"