Skip to content

Commit a0a5d87

Browse files
committed
Update workflow templates
1 parent d6727a2 commit a0a5d87

File tree

2 files changed

+149
-44
lines changed

2 files changed

+149
-44
lines changed

lib/node_modules/@stdlib/_tools/scripts/templates/workflow_bundle.yml.txt

Lines changed: 148 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,10 @@ jobs:
3232
runs-on: ubuntu-latest
3333
steps:
3434
- 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
3739
- name: Copy files to deno directory
3840
run: |
3941
mkdir -p deno
@@ -85,18 +87,51 @@ jobs:
8587

8688
# Create package.json file for deno branch:
8789
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-
user_email: '[email protected]'
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
100135
- name: Send status to Slack channel in case of failure
101136
uses: act10ns/slack@v1
102137
with:
@@ -108,8 +143,10 @@ jobs:
108143
runs-on: ubuntu-latest
109144
steps:
110145
- 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
113150
- name: Copy files to umd directory
114151
run: |
115152
mkdir -p umd
@@ -123,7 +160,7 @@ jobs:
123160
run: |
124161
npm install || npm install || npm install
125162
timeout-minutes: 15
126-
- name: Extract Alias
163+
- name: Extract alias
127164
id: extract-alias
128165
run: |
129166
alias=$(grep -E 'require\(' README.md | head -n 1 | sed -E 's/^var ([a-zA-Z0-9_]+) = .+/\1/')
@@ -159,18 +196,51 @@ jobs:
159196

160197
# Create package.json file for umd branch:
161198
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-
user_email: '[email protected]'
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
174244
- name: Send status to Slack channel in case of failure
175245
uses: act10ns/slack@v1
176246
with:
@@ -182,8 +252,10 @@ jobs:
182252
runs-on: ubuntu-latest
183253
steps:
184254
- 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
187259
- name: Copy files to umd directory
188260
run: |
189261
mkdir -p esm
@@ -239,18 +311,51 @@ jobs:
239311

240312
# Create package.json file for esm branch:
241313
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-
user_email: '[email protected]'
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
254359
- name: Send status to Slack channel in case of failure
255360
uses: act10ns/slack@v1
256361
with:

lib/node_modules/@stdlib/_tools/scripts/templates/workflow_test_bundles.yml.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ name: test_bundles
2222
# Workflow triggers:
2323
on:
2424
workflow_run:
25-
workflows: ["test"]
25+
workflows: ["bundle"]
2626
types: [completed]
2727
workflow_dispatch:
2828

0 commit comments

Comments
 (0)