Skip to content

Commit d580122

Browse files
authored
ci: Add rebundle dist/ workflow (#44)
2 parents 33791b5 + ec06059 commit d580122

File tree

2 files changed

+39
-7
lines changed

2 files changed

+39
-7
lines changed

.github/workflows/ci.yml

+5-7
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ permissions:
1010
contents: read
1111
pull-requests: write
1212

13+
concurrency:
14+
group: ${{ github.ref }}
15+
cancel-in-progress: true
16+
1317
jobs:
1418
check:
1519
runs-on: ubuntu-latest
@@ -27,13 +31,7 @@ jobs:
2731
- uses: ./.github/actions/setup-deno-with-cache
2832
- name: Rebuild the dist/ directory
2933
run: deno task bundle
30-
- name: Compare the expected and actual dist/ directories
31-
run: |
32-
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
33-
echo "Detected uncommitted changes after build. See status below:"
34-
git diff
35-
exit 1
36-
fi
34+
3735
# post processes
3836
- name: Upload dist for post job
3937
if: ${{ always() }}

.github/workflows/rebundle.yml

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
name: Rebundle dist
2+
3+
on:
4+
push:
5+
branches: [ "main" ]
6+
workflow_dispatch:
7+
8+
jobs:
9+
# Rebundle dist and push if changed from main branch
10+
rebundle-dist:
11+
runs-on: ubuntu-latest
12+
steps:
13+
# To bypass branch rule sets, we need to use GitHub App that allowed to bypass status check.
14+
- uses: actions/create-github-app-token@v1
15+
id: app-token
16+
with:
17+
app-id: ${{ secrets.BYPASS_APP_ID }}
18+
private-key: ${{ secrets.BYPASS_APP_PRIVATE_KEY }}
19+
- uses: actions/checkout@v4
20+
with:
21+
token: ${{ steps.app-token.outputs.token }}
22+
23+
- uses: ./.github/actions/setup-deno-with-cache
24+
- name: Rebuild the dist/ directory
25+
run: deno task bundle
26+
- name: Commit and push dist/ if changed
27+
run: |
28+
if [ "$(git diff --ignore-space-at-eol dist/ | wc -l)" -gt "0" ]; then
29+
git config --global user.name "github-actions"
30+
git config --global user.email "github-actions@github.com"
31+
git add -u dist
32+
git commit -m "deno task bundle"
33+
git push origin main
34+
fi

0 commit comments

Comments
 (0)