Skip to content

Commit cfc8a59

Browse files
committed
ci: deploy workflow and deploy after recording results
1 parent 8807dc7 commit cfc8a59

4 files changed

Lines changed: 85 additions & 1 deletion

File tree

.github/workflows/compat-check.yml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,3 +212,20 @@ jobs:
212212
git pull --rebase
213213
done
214214
exit 1
215+
# Commits made with the Actions token do not trigger the deploy
216+
# workflow, so the results are deployed from here.
217+
- name: Deploy
218+
if: env.CLOUDFLARE_API_TOKEN != ''
219+
env:
220+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
221+
run: |
222+
npm ci
223+
npx vite build
224+
- uses: cloudflare/wrangler-action@v3
225+
if: env.CLOUDFLARE_API_TOKEN != ''
226+
env:
227+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
228+
with:
229+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
230+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
231+
command: deploy

.github/workflows/deploy.yml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Deploys the Worker and the app to Cloudflare on every push to the default
2+
# branch that touches something deployable. Needs two repository secrets:
3+
# CLOUDFLARE_API_TOKEN an API token with the "Edit Cloudflare Workers" template
4+
# CLOUDFLARE_ACCOUNT_ID the account that owns the Worker
5+
name: deploy
6+
7+
on:
8+
push:
9+
branches: [main]
10+
paths:
11+
- "worker/**"
12+
- "shared/**"
13+
- "web/**"
14+
- "data/**"
15+
- "schemas/**"
16+
- "index.html"
17+
- "vite.config.ts"
18+
- "wrangler.jsonc"
19+
- "package.json"
20+
- "package-lock.json"
21+
- ".github/workflows/deploy.yml"
22+
workflow_dispatch:
23+
24+
concurrency:
25+
group: deploy
26+
cancel-in-progress: true
27+
28+
permissions:
29+
contents: read
30+
31+
jobs:
32+
deploy:
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v4
36+
- uses: actions/setup-node@v4
37+
with:
38+
node-version: 22
39+
cache: npm
40+
- run: npm ci
41+
- run: npm test
42+
- run: npm run check
43+
- run: npx vite build
44+
- uses: cloudflare/wrangler-action@v3
45+
with:
46+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
47+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
48+
command: deploy

README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,19 @@ npm run build # client and Worker into dist/, with a generated wrangler.js
104104
npm run deploy # build, then wrangler deploy
105105
npm test && npm run check
106106
```
107+
108+
## Deploying
109+
110+
One-time setup:
111+
112+
1. `npx wrangler login`, then `npx wrangler kv namespace create COMPAT_KV` and
113+
paste the printed id into `wrangler.jsonc`.
114+
2. Add two repository secrets: `CLOUDFLARE_API_TOKEN` (an API token created
115+
from the "Edit Cloudflare Workers" template) and `CLOUDFLARE_ACCOUNT_ID`.
116+
3. For the custom domain, uncomment the `routes` entry in `wrangler.jsonc`
117+
once the `nativescript.org` zone lives on that account.
118+
119+
After that, the `deploy` workflow deploys every push to `main` that touches
120+
deployable files, and `compat-check` deploys the results it records. From a
121+
machine that is logged in, `npm run deploy` does the same by hand. The hourly
122+
cron trigger is part of the deployment.

wrangler.jsonc

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
"not_found_handling": "none"
1111
},
1212
"kv_namespaces": [
13-
// `id` is a placeholder until the namespace exists; `wrangler dev` uses local storage.
13+
// Create once with `npx wrangler kv namespace create COMPAT_KV` and paste the id
14+
// it prints; `wrangler dev` ignores it and uses local storage.
1415
{ "binding": "COMPAT_KV", "id": "00000000000000000000000000000000" }
1516
],
17+
// Once the nativescript.org zone is on the deploying account:
18+
// "routes": [{ "pattern": "compatibility.nativescript.org", "custom_domain": true }],
1619
"triggers": { "crons": ["0 * * * *"] },
1720
"vars": {
1821
"NPM_REGISTRY": "https://registry.npmjs.org/"

0 commit comments

Comments
 (0)