Repository navigation
70 lines (61 loc) · 2.08 KB
/
Copy pathdeploy.yml
File metadata and controls
70 lines (61 loc) · 2.08 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
name: Deploy
on:
push:
branches: [master]
# Manual re-run from the Actions tab.
workflow_dispatch:
# Never let two deploys race; a newer push waits for the one in flight.
concurrency:
group: deploy
cancel-in-progress: false
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect changed packs
id: packs
env:
BEFORE: ${{ github.event.before }}
shell: bash
run: |
if [[ "$GITHUB_EVENT_NAME" == "workflow_dispatch" || -z "$BEFORE" ]] \
|| ! git cat-file -e "$BEFORE^{commit}" 2>/dev/null; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
files="$(git diff --name-only "$BEFORE" "$GITHUB_SHA" -- packs/)"
if [[ -n "$files" ]]; then
echo "changed=true" >> "$GITHUB_OUTPUT"
else
echo "changed=false" >> "$GITHUB_OUTPUT"
fi
fi
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run typecheck
- run: npm test
- run: npx playwright install --with-deps chromium
- run: npm run test:browser
# Applies only the migrations D1 hasn't seen yet, so it's a no-op
# when none landed. Runs before the deploy so new code finds its tables.
- name: Migrate the database
run: npm run migrate:remote
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Deploy the Worker
run: npm run deploy
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
- name: Reseed changed community packs
if: steps.packs.outputs.changed == 'true'
run: npm run seed:remote
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}