-
Notifications
You must be signed in to change notification settings - Fork 132
312 lines (283 loc) · 11.2 KB
/
cd.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
308
309
310
311
312
name: Continuous deployment
on:
push:
branches:
- master
- reorg
tags:
- 'v*'
jobs:
deploy-gcweb:
runs-on: ubuntu-latest
environment: github-cd
strategy:
matrix:
node-version: [12.x]
env:
REPO_GCWEB: GCWeb
REPO_JEKYLL: gcweb-jekyll
REPO_COMPILED_DEMOS: gcweb-compiled-demos
REPO_DIST: themes-dist
REPO_DIST_CDN: themes-cdn
steps:
- uses: actions/checkout@v2
- name: Extract tag or branch name
id: ref_name
uses: actions/github-script@v3
with:
github-token: ${{ secrets.my_token }}
result-encoding: string
# act use "\" and githbu use "/"
script: |
return context.ref.replace(/\/?refs\/heads\//, '').replace(/\\?refs\\heads\\/, '').replace(/\/?refs\/tags\//, '').replace(/\\?refs\\tags\\/, '')
- name: Check if it a tag
id: ref_tags
uses: actions/github-script@v3
with:
github-token: ${{ secrets.my_token }}
result-encoding: string
# act use "\" and githbu use "/"
script: |
return context.ref.startsWith("\\refs\\tags\\") || context.ref.startsWith("/refs/tags/") || context.ref.startsWith("refs/tags/") || context.ref.startsWith("refs\\tags\\") || ''
- name: Tag or branch info
env:
ref_name: ${{ steps.ref_name.outputs.result }}
is_tags: ${{ steps.ref_tags.outputs.result }}
run: |
echo Ref name: ${{ env.ref_name }}
echo Is tag: ${{ env.is_tags }}
# - name: Cache node modules
# uses: actions/cache@v2
# if: ${{ !env.ACT }}
# env:
# cache-name: cache-node-modules
# with:
# # npm cache files are stored in '~/.npm' on Linux/macOS
# path: ~/.npm
# key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
# restore-keys: |
# ${{ runner.os }}-build-${{ env.cache-name }}-
# ${{ runner.os }}-build-
# ${{ runner.os }}-
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install dependencies
run: |
npm i -g bower grunt-cli
npm ci
- name: Copy the missing _sprite_share.scss file - related to GCWeb#1737 about wet-boew#cc340a6 commit
run: |
curl https://gist.githubusercontent.com/duboisp/d69787b300eb1f4d40f937508e10d013/raw/86e7a0b15ad6a695754599e9793e986b460bf514/_sprites_share.scss >> _sprites_share.scss
mv _sprites_share.scss node_modules/wet-boew/src/plugins/share/sprites/_sprites_share.scss
- name: Checkout wet-boew latest build
if: ${{ env.ACT }}
run: |
git clone --depth 1 https://github.com/wet-boew/wet-boew-cdn.git --branch v4.0-dist ~wet-boew-cdn
mkdir -p node_modules/wet-boew/dist/wet-boew
mv ~wet-boew-cdn/* node_modules/wet-boew/dist/wet-boew
- name: Build GCWeb
if: ${{ !env.ACT }}
run: grunt dist
- name: Build GCWeb (without pre-test)
if: ${{ env.ACT }}
run: grunt dist-act
- name: Git config
run: |
git config --global user.name "${{ secrets.my_username }}"
git config --global user.email "${{ secrets.my_email }}"
#
# Jekyll theme
#
- name: Jekyll theme - Applying changes
env:
GITHUB_TOKEN: ${{ secrets.my_token }}
run: |
git clone --depth 1 https://github.com/${{ github.repository_owner }}/${{ env.REPO_JEKYLL }}.git ~gcweb-jekyll
rm -rf ~gcweb-jekyll/_includes
rm -rf ~gcweb-jekyll/_layouts
mv ~jekyll-dist/_includes ~gcweb-jekyll/_includes
mv ~jekyll-dist/_layouts ~gcweb-jekyll/_layouts
cd ~gcweb-jekyll
git add .
git commit -m "CD ${{ github.run_id }}: Update GCWeb jekyll theme files" --allow-empty
- name: Jekyll theme - Deploy
uses: ad-m/github-push-action@master
with:
repository: ${{ github.repository_owner }}/${{ env.REPO_JEKYLL }}
directory: ~gcweb-jekyll
branch: master
github_token: ${{ secrets.my_token }}
#
# Draft release of jekyll GCWeb theme, the actual release need to be manual because it's public API is different
#
- name: Jekyll theme - Create Draft Release
if: ${{ env.is_tags != '' }}
uses: actions/github-script@v3
env:
commitish: master
repo: ${{ env.REPO_JEKYLL }}
ref_name: ${{ steps.ref_name.outputs.result }}
is_tags: ${{ steps.ref_tags.outputs.result }}
with:
github-token: ${{ secrets.my_token }}
script: |
github.repos.createRelease({
owner: context.repo.owner,
repo: process.env.repo,
tag_name: process.env.ref_name,
name: 'Draft Release ' + process.env.ref_name + ' (' + context.runId + ')',
target_commitish: process.env.commitish,
draft: true
});
#
# Compiled demos
#
- name: Compiled demos - Applying changes
run: |
git clone --depth 1 https://github.com/${{ github.repository_owner }}/${{ env.REPO_COMPILED_DEMOS }}.git ~gcweb-compiled-demos
rm -rf ~gcweb-compiled-demos/_wetboew-demos
rm -rf ~gcweb-compiled-demos/méli-mélo-demos
rm -rf ~gcweb-compiled-demos/_data/méli-mélo.json
mv _wetboew-demos ~gcweb-compiled-demos/_wetboew-demos
mv méli-mélo-demos ~gcweb-compiled-demos/méli-mélo-demos
mkdir -p ~gcweb-compiled-demos/_data
cp _data/méli-mélo.json ~gcweb-compiled-demos/_data/méli-mélo.json
cd ~gcweb-compiled-demos
git add .
git commit -m "CD ${{ github.run_id }}: Update GCWeb compiled demos files" --allow-empty
- name: Compiled demos - Deploy
uses: ad-m/github-push-action@master
with:
repository: ${{ github.repository_owner }}/${{ env.REPO_COMPILED_DEMOS }}
directory: ~gcweb-compiled-demos
branch: master
github_token: ${{ secrets.my_token }}
- name: Compiled demos - Create release
if: ${{ env.is_tags != '' }}
uses: actions/github-script@v3
env:
commitish: master
repo: ${{ env.REPO_COMPILED_DEMOS }}
ref_name: ${{ steps.ref_name.outputs.result }}
is_tags: ${{ steps.ref_tags.outputs.result }}
with:
github-token: ${{ secrets.my_token }}
script: |
github.repos.createRelease({
owner: context.repo.owner,
repo: process.env.repo,
tag_name: process.env.ref_name,
name: 'Release ' + process.env.ref_name + ' (' + context.runId + ')',
target_commitish: process.env.commitish
});
#
# GCWeb Dist
#
- name: Dist - Applying changes
run: |
git clone --depth 1 https://github.com/${{ github.repository_owner }}/${{ env.REPO_DIST }}.git --branch GCWeb ~gcweb-dist
rm -rf ~gcweb-dist/wet-boew
rm -rf ~gcweb-dist/GCWeb
mv dist/wet-boew ~gcweb-dist/wet-boew
mv dist/GCWeb ~gcweb-dist/GCWeb
cp Licence-fr.txt ~gcweb-dist/GCWeb/Licence-fr.txt
cp License-en.txt ~gcweb-dist/GCWeb/License-en.txt
cd ~gcweb-dist
git add .
git commit -m "CD ${{ github.run_id }}: Update GCWeb dist files" --allow-empty
- name: Dist - Deploy in GCWeb branch
uses: ad-m/github-push-action@master
with:
repository: ${{ github.repository_owner }}/${{ env.REPO_DIST }}
directory: ~gcweb-dist
branch: GCWeb
github_token: ${{ secrets.my_token }}
- name: Dist - Create release
if: ${{ env.is_tags != '' }}
uses: actions/github-script@v3
env:
commitish: GCWeb
repo: ${{ env.REPO_DIST }}
ref_name: ${{ steps.ref_name.outputs.result }}-gcweb
is_tags: ${{ steps.ref_tags.outputs.result }}
with:
github-token: ${{ secrets.my_token }}
script: |
github.repos.createRelease({
owner: context.repo.owner,
repo: process.env.repo,
tag_name: process.env.ref_name,
name: 'Release ' + process.env.ref_name + ' (' + context.runId + ')',
target_commitish: process.env.commitish
});
- name: Dist - Update submodule
run: |
git clone --depth 1 https://github.com/${{ github.repository_owner }}/${{ env.REPO_DIST }}.git --branch gh-pages ~gcweb-dist-submodule
cd ~gcweb-dist-submodule
git submodule update --init --depth 1 GCWeb
cd GCWeb
git remote add neworigin https://github.com/${{ github.repository_owner }}/${{ env.REPO_DIST }}.git
git fetch --depth 1 neworigin GCWeb
git reset --hard neworigin/GCWeb
cd ..
git add .
git commit -m "CD ${{ github.run_id }}: Update submodule GCWeb dist" --allow-empty
- name: Dist - Deploy submodule updated
uses: ad-m/github-push-action@master
with:
repository: ${{ github.repository_owner }}/${{ env.REPO_DIST }}
directory: ~gcweb-dist-submodule
branch: gh-pages
github_token: ${{ secrets.my_token }}
#
# GCWeb Dist CDN
#
- name: Dist CDN - Applying changes
run: |
git clone --depth 1 https://github.com/${{ github.repository_owner }}/${{ env.REPO_DIST_CDN }}.git --branch GCWeb ~gcweb-cdn
rm -rf ~gcweb-cdn/*
cp -r ~gcweb-dist/GCWeb/. ~gcweb-cdn/
cd ~gcweb-cdn
git add .
git commit -m "CD ${{ github.run_id }}: Update GCWeb dist cdn files" --allow-empty
- name: Dist CDN - Deploy in GCWeb branch
uses: ad-m/github-push-action@master
with:
repository: ${{ github.repository_owner }}/${{ env.REPO_DIST_CDN }}
directory: ~gcweb-cdn
branch: GCWeb
github_token: ${{ secrets.my_token }}
- name: Dist CDN - Create release
uses: actions/github-script@v3
env:
commitish: GCWeb
repo: ${{ env.REPO_DIST_CDN }}
ref_name: ${{ steps.ref_name.outputs.result }}-gcweb
is_tags: ${{ steps.ref_tags.outputs.result }}
if: ${{ env.is_tags != '' }}
with:
github-token: ${{ secrets.my_token }}
script: |
github.repos.createRelease({
owner: context.repo.owner,
repo: process.env.repo,
tag_name: process.env.ref_name,
name: 'Release ' + process.env.ref_name + ' (' + context.runId + ')',
target_commitish: process.env.commitish
});
#
# Refresh GCWeb GitHub pages
#
- name: Dist CDN - Applying changes
uses: actions/github-script@v3
env:
repo: ${{ env.REPO_GCWEB }}
with:
github-token: ${{ secrets.my_token }}
script: |
github.repos.requestPagesBuild({
owner: context.repo.owner,
repo: process.env.repo
});