32
32
runs-on: ubuntu-latest
33
33
steps:
34
34
- uses: actions/checkout@v3
35
- with:
36
- ref: production
35
+ - name: Checkout production branch
36
+ run: |
37
+ git fetch --all
38
+ git checkout -b production origin/production
37
39
- name: Copy files to deno directory
38
40
run: |
39
41
mkdir -p deno
@@ -85,18 +87,51 @@ jobs:
85
87
86
88
# Create package.json file for deno branch:
87
89
jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./mod.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./deno/package.json
88
-
89
- - name: Publish to deno branch
90
- uses: peaceiris/actions-gh-pages@v3
91
- with:
92
- github_token: ${{ secrets.GITHUB_TOKEN }}
93
- publish_dir: ./deno
94
- publish_branch: deno
95
- force_orphan: true
96
- user_name: 'stdlib-bot'
97
-
98
- commit_message: 'Auto-generated commit'
99
- enable_jekyll: true
90
+ - name: Configure git
91
+ run: |
92
+ git config --local user.email "
[email protected] "
93
+ git config --local user.name "stdlib-bot"
94
+ - name: Check if remote `deno` branch exists
95
+ id: deno-branch-exists
96
+ continue-on-error: true
97
+ run: |
98
+ git ls-remote --exit-code --heads origin deno
99
+ if [ $? -eq 0 ]; then
100
+ echo "::set-output name=remote-exists::true"
101
+ else
102
+ echo "::set-output name=remote-exists::false"
103
+ fi
104
+ - name: If `deno` exists, checkout branch and rebase on `main`
105
+ if: steps.deno-branch-exists.outputs.remote-exists
106
+ continue-on-error: true
107
+ run: |
108
+ git checkout -b deno origin/deno
109
+ git rebase main -s recursive -X ours
110
+ while [ $? -ne 0 ]; do
111
+ git rebase --skip
112
+ done
113
+ - name: If `deno` does not exist, checkout `main` and create `deno` branch
114
+ if: ${{ steps.deno-branch-exists.outputs.remote-exists == false }}
115
+ run: |
116
+ git checkout main
117
+ git checkout -b deno
118
+ - name: Delete everything in current directory aside from deno folder
119
+ run: |
120
+ find . -type 'f' | grep -v -e "deno" -e ".git/" | xargs rm
121
+ find . -mindepth 1 -type 'd' | grep -v -e "deno" -e ".git" | xargs rm -rf
122
+ - name: Move deno directory to root
123
+ run: |
124
+ mv ./deno/* .
125
+ rmdir ./deno
126
+ - name: Commit changes
127
+ run: |
128
+ git add -A
129
+ git commit -m "Auto-generated commit"
130
+ - name: Push changes
131
+ run: |
132
+ SLUG=${{ github.repository }}
133
+ echo "Pushing changes to $SLUG..."
134
+ git push "https://$GITHUB_ACTOR:
[email protected] /$SLUG.git" deno --force
100
135
- name: Send status to Slack channel in case of failure
101
136
uses: act10ns/slack@v1
102
137
with:
@@ -108,8 +143,10 @@ jobs:
108
143
runs-on: ubuntu-latest
109
144
steps:
110
145
- uses: actions/checkout@v3
111
- with:
112
- ref: production
146
+ - name: Checkout production branch
147
+ run: |
148
+ git fetch --all
149
+ git checkout -b production origin/production
113
150
- name: Copy files to umd directory
114
151
run: |
115
152
mkdir -p umd
@@ -123,7 +160,7 @@ jobs:
123
160
run: |
124
161
npm install || npm install || npm install
125
162
timeout-minutes: 15
126
- - name: Extract Alias
163
+ - name: Extract alias
127
164
id: extract-alias
128
165
run: |
129
166
alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/')
@@ -159,18 +196,51 @@ jobs:
159
196
160
197
# Create package.json file for umd branch:
161
198
jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "main": "./bundle.js", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./umd/package.json
162
-
163
- - name: Publish to umd branch
164
- uses: peaceiris/actions-gh-pages@v3
165
- with:
166
- github_token: ${{ secrets.GITHUB_TOKEN }}
167
- publish_dir: ./umd
168
- publish_branch: umd
169
- force_orphan: true
170
- user_name: 'stdlib-bot'
171
-
172
- commit_message: 'Auto-generated commit'
173
- enable_jekyll: true
199
+ - name: Configure git
200
+ run: |
201
+ git config --local user.email "
[email protected] "
202
+ git config --local user.name "stdlib-bot"
203
+ - name: Check if remote `umd` branch exists
204
+ id: umd-branch-exists
205
+ continue-on-error: true
206
+ run: |
207
+ git ls-remote --exit-code --heads origin umd
208
+ if [ $? -eq 0 ]; then
209
+ echo "::set-output name=remote-exists::true"
210
+ else
211
+ echo "::set-output name=remote-exists::false"
212
+ fi
213
+ - name: If `umd` exists, checkout branch and rebase on `main`
214
+ if: steps.umd-branch-exists.outputs.remote-exists
215
+ continue-on-error: true
216
+ run: |
217
+ git checkout -b umd origin/umd
218
+ git rebase main -s recursive -X ours
219
+ while [ $? -ne 0 ]; do
220
+ git rebase --skip
221
+ done
222
+ - name: If `umd` does not exist, checkout `main` and create `umd` branch
223
+ if: ${{ steps.umd-branch-exists.outputs.remote-exists == false }}
224
+ run: |
225
+ git checkout main
226
+ git checkout -b umd
227
+ - name: Delete everything in current directory aside from umd folder
228
+ run: |
229
+ find . -type 'f' | grep -v -e "umd" -e ".git/" | xargs rm
230
+ find . -mindepth 1 -type 'd' | grep -v -e "umd" -e ".git" | xargs rm -rf
231
+ - name: Move umd directory to root
232
+ run: |
233
+ mv ./umd/* .
234
+ rmdir ./umd
235
+ - name: Commit changes
236
+ run: |
237
+ git add -A
238
+ git commit -m "Auto-generated commit"
239
+ - name: Push changes
240
+ run: |
241
+ SLUG=${{ github.repository }}
242
+ echo "Pushing changes to $SLUG..."
243
+ git push "https://$GITHUB_ACTOR:
[email protected] /$SLUG.git" umd --force
174
244
- name: Send status to Slack channel in case of failure
175
245
uses: act10ns/slack@v1
176
246
with:
@@ -182,8 +252,10 @@ jobs:
182
252
runs-on: ubuntu-latest
183
253
steps:
184
254
- uses: actions/checkout@v3
185
- with:
186
- ref: production
255
+ - name: Checkout production branch
256
+ run: |
257
+ git fetch --all
258
+ git checkout -b production origin/production
187
259
- name: Copy files to umd directory
188
260
run: |
189
261
mkdir -p esm
@@ -239,18 +311,51 @@ jobs:
239
311
240
312
# Create package.json file for esm branch:
241
313
jq --indent 2 '{"name": .name, "version": .version, "description": .description, "license": .license, "type": "module", "main": "./index.mjs", "homepage": .homepage, "repository": .repository, "bugs": .bugs, "keywords": .keywords, "funding": .funding}' package.json > ./esm/package.json
242
-
243
- - name: Publish to esm branch
244
- uses: peaceiris/actions-gh-pages@v3
245
- with:
246
- github_token: ${{ secrets.GITHUB_TOKEN }}
247
- publish_dir: ./esm
248
- publish_branch: esm
249
- force_orphan: true
250
- user_name: 'stdlib-bot'
251
-
252
- commit_message: 'Auto-generated commit'
253
- enable_jekyll: true
314
+ - name: Configure git
315
+ run: |
316
+ git config --local user.email "
[email protected] "
317
+ git config --local user.name "stdlib-bot"
318
+ - name: Check if remote `esm` branch exists
319
+ id: esm-branch-exists
320
+ continue-on-error: true
321
+ run: |
322
+ git ls-remote --exit-code --heads origin esm
323
+ if [ $? -eq 0 ]; then
324
+ echo "::set-output name=remote-exists::true"
325
+ else
326
+ echo "::set-output name=remote-exists::false"
327
+ fi
328
+ - name: If `esm` exists, checkout branch and rebase on `main`
329
+ if: steps.esm-branch-exists.outputs.remote-exists
330
+ continue-on-error: true
331
+ run: |
332
+ git checkout -b esm origin/esm
333
+ git rebase main -s recursive -X ours
334
+ while [ $? -ne 0 ]; do
335
+ git rebase --skip
336
+ done
337
+ - name: If `esm` does not exist, checkout `main` and create `esm` branch
338
+ if: ${{ steps.esm-branch-exists.outputs.remote-exists == false }}
339
+ run: |
340
+ git checkout main
341
+ git checkout -b esm
342
+ - name: Delete everything in current directory aside from esm folder
343
+ run: |
344
+ find . -type 'f' | grep -v -e "esm" -e ".git/" | xargs rm
345
+ find . -mindepth 1 -type 'd' | grep -v -e "esm" -e ".git" | xargs rm -rf
346
+ - name: Move esm directory to root
347
+ run: |
348
+ mv ./esm/* .
349
+ rmdir ./esm
350
+ - name: Commit changes
351
+ run: |
352
+ git add -A
353
+ git commit -m "Auto-generated commit"
354
+ - name: Push changes
355
+ run: |
356
+ SLUG=${{ github.repository }}
357
+ echo "Pushing changes to $SLUG..."
358
+ git push "https://$GITHUB_ACTOR:
[email protected] /$SLUG.git" esm --force
254
359
- name: Send status to Slack channel in case of failure
255
360
uses: act10ns/slack@v1
256
361
with:
0 commit comments