-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (130 loc) · 3.96 KB
/
pipeline.yml
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
121
122
123
124
125
126
127
128
129
130
131
132
name: Deploy
on:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
name: 'Test'
steps:
- name: 'Checkout repo'
uses: actions/checkout@v3
- name: 'Set up Node'
uses: actions/setup-node@v3
with:
node-version: 21.6.*
cache: npm
- name: 'Install dependencies'
run: npm ci
- name: 'Migrate'
run: npm run migrations:apply
- name: 'Run tests'
run: npm test
- name: 'Build app'
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "3.28.2"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: deploy --outdir dist-app --dry-run
- name: 'Build auth'
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "3.28.2"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: deploy --config wrangler-auth.toml --outdir dist-auth --dry-run
- name: 'Build worker'
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "3.28.2"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: deploy --config wrangler-worker.toml --outdir dist-worker --dry-run
- name: 'Zip app'
run: zip -r app.zip dist-app public migrations wrangler.toml
- name: 'Zip auth'
run: zip -r auth.zip dist-auth wrangler-auth.toml
- name: 'Zip worker'
run: zip -r worker.zip dist-worker wrangler-worker.toml
- name: 'Save app artifact'
uses: actions/upload-artifact@v3
with:
name: app
path: app.zip
- name: 'Save auth artifact'
uses: actions/upload-artifact@v3
with:
name: auth
path: auth.zip
- name: 'Save worker artifact'
uses: actions/upload-artifact@v3
with:
name: worker
path: worker.zip
migrate:
name: 'Migrate database'
needs: [test]
runs-on: ubuntu-latest
steps:
- name: 'Download app'
uses: actions/download-artifact@v3
with:
name: app
- name: 'Unzip app artifact'
run: unzip app.zip
- name: 'Migrate database on Cloudflare'
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "3.28.2"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: d1 migrations apply starter-db
deploy-app:
name: 'Deploy app'
needs: [migrate]
runs-on: ubuntu-latest
steps:
- name: 'Download app'
uses: actions/download-artifact@v3
with:
name: app
- name: 'Unzip app artifact'
run: unzip app.zip
- name: 'Deploy app to Cloudflare'
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "3.28.2"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: deploy dist-app/index.js --no-bundle
deploy-auth:
name: 'Deploy auth'
needs: [migrate]
runs-on: ubuntu-latest
steps:
- name: 'Download auth'
uses: actions/download-artifact@v3
with:
name: auth
- name: 'Unzip auth artifact'
run: unzip auth.zip
- name: 'Deploy auth to Cloudflare'
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "3.28.2"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: deploy --config wrangler-auth.toml dist-auth/auth.js --no-bundle
deploy-worker:
name: 'Deploy worker'
needs: [migrate]
runs-on: ubuntu-latest
steps:
- name: 'Download worker'
uses: actions/download-artifact@v3
with:
name: worker
- name: 'Unzip worker artifact'
run: unzip worker.zip
- name: 'Deploy worker to Cloudflare'
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "3.28.2"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
command: deploy --config wrangler-worker.toml dist-worker/worker.js --no-bundle