Skip to content

Commit cefc1ca

Browse files
committed
build dist and auto-commit on main
1 parent 54dfe04 commit cefc1ca

1 file changed

Lines changed: 44 additions & 7 deletions

File tree

.github/workflows/ci.yml

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,21 @@ jobs:
1818
- run: npm ci
1919
- run: npm run typecheck
2020
- run: npm run build
21-
- name: Verify dist/ is up to date
22-
run: |
23-
if [ -n "$(git status --porcelain dist)" ]; then
24-
echo "::error::dist/ is out of date. Run 'npm run build' and commit the result."
25-
git diff -- dist
26-
exit 1
27-
fi
21+
- uses: actions/upload-artifact@v4
22+
with:
23+
name: dist
24+
path: dist
2825

2926
smoke-test-browser:
3027
name: Smoke test (browser driver, Wikipedia)
28+
needs: build
3129
runs-on: ubuntu-latest
3230
steps:
3331
- uses: actions/checkout@v4
32+
- uses: actions/download-artifact@v4
33+
with:
34+
name: dist
35+
path: dist
3436
- uses: ./
3537
with:
3638
origin: https://en.wikipedia.org
@@ -44,10 +46,45 @@ jobs:
4446

4547
smoke-test-terminal:
4648
name: Smoke test (terminal driver, head)
49+
needs: build
4750
runs-on: ubuntu-latest
4851
steps:
4952
- uses: actions/checkout@v4
53+
- uses: actions/download-artifact@v4
54+
with:
55+
name: dist
56+
path: dist
5057
- uses: ./
5158
with:
5259
driver: terminal
5360
command: head -n 50
61+
62+
publish-dist:
63+
name: Publish dist to main
64+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
65+
needs: [smoke-test-browser, smoke-test-terminal]
66+
runs-on: ubuntu-latest
67+
permissions:
68+
contents: write
69+
concurrency:
70+
group: publish-dist-${{ github.ref }}
71+
cancel-in-progress: false
72+
steps:
73+
- uses: actions/checkout@v4
74+
with:
75+
ref: ${{ github.ref }}
76+
- uses: actions/download-artifact@v4
77+
with:
78+
name: dist
79+
path: dist
80+
- name: Commit dist if changed
81+
run: |
82+
if [ -z "$(git status --porcelain dist)" ]; then
83+
echo "dist already up to date."
84+
exit 0
85+
fi
86+
git config user.name "github-actions[bot]"
87+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
88+
git add dist
89+
git commit -m "chore: rebuild dist [skip ci]"
90+
git push

0 commit comments

Comments
 (0)