-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (112 loc) · 3.42 KB
/
Copy pathci.yml
File metadata and controls
120 lines (112 loc) · 3.42 KB
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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
workflow_dispatch:
permissions:
# `contents: write` is required so the `build-dist` reusable workflow
# (`runsascoded/npm-dist`) can push to the `dist` branch. GH validates
# this at workflow-load time and refuses to schedule with a startup
# failure otherwise.
contents: write
pages: write
id-token: write
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: false
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Build lib
run: pnpm build
- name: Vitest
run: pnpm test
- name: Typecheck
run: pnpm typecheck
build-pages:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Build lib (site consumes via link:..)
run: pnpm build
- name: Install site deps
run: pnpm install --frozen-lockfile
working-directory: site
- name: Build site
run: pnpm build
working-directory: site
# SPA fallback for react-router-dom routes (`/mock`, `/http`, …)
- name: SPA fallback
run: cp site/dist/index.html site/dist/404.html
- uses: actions/upload-pages-artifact@v3
with:
path: site/dist
deploy-pages:
needs: build-pages
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- id: deployment
uses: actions/deploy-pages@v4
build-dist:
needs: test
if: github.ref == 'refs/heads/main'
uses: runsascoded/npm-dist/.github/workflows/build-dist.yml@v1
# Default flattening mode: npm-dist copies `dist/`'s contents to the
# dist-branch root and rewrites the `./dist/...` paths in `exports`
# to `./...` to match. We previously used `preserve_dirs: dist` to
# keep paths intact, but v1's merge step transforms paths
# unconditionally on subsequent runs, leaving exports pointing at
# `./index.js` while files still lived under `./dist/index.js` →
# validator failure. Default mode keeps both in sync.
deploy-worker:
needs: test
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 10
- uses: actions/setup-node@v4
with:
node-version: 22
cache: pnpm
- run: pnpm install --frozen-lockfile
- name: Build lib (worker consumes via link:../..)
run: pnpm build
- name: Install worker deps
run: pnpm install --frozen-lockfile
working-directory: site/worker
- name: Deploy via wrangler
uses: cloudflare/wrangler-action@v3
with:
workingDirectory: site/worker
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }}
packageManager: pnpm