-
-
Notifications
You must be signed in to change notification settings - Fork 1
109 lines (90 loc) · 2.81 KB
/
admin-deploy.yml
File metadata and controls
109 lines (90 loc) · 2.81 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
name: Deploy Admin
on:
push:
branches: [main]
paths: ['admin/**']
release:
types: [published]
concurrency:
group: admin-deploy-${{ github.ref }}
cancel-in-progress: true
defaults:
run:
working-directory: admin
jobs:
typecheck:
name: Type Check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: admin/package-lock.json
- name: Install dependencies
run: npm ci
- name: Run type check
run: npm run check
deploy-staging:
name: Deploy to Staging
needs: typecheck
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
environment: staging
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: admin/package-lock.json
- name: Install dependencies
run: npm ci
- name: Update wrangler.toml with database ID
env:
D1_DB_ID: ${{ secrets.D1_DATABASE_ID }}
run: sed -i "s/YOUR_D1_DATABASE_ID/$D1_DB_ID/g" wrangler.toml
- name: Build
run: npm run build
- name: Deploy to Cloudflare Pages (staging)
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy .svelte-kit/cloudflare --project-name=skyreader-admin-staging --commit-dirty=true
workingDirectory: admin
deploy-production:
name: Deploy to Production
needs: typecheck
if: github.event_name == 'release'
runs-on: ubuntu-latest
environment: production
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: admin/package-lock.json
- name: Install dependencies
run: npm ci
- name: Update wrangler.toml with database ID
env:
D1_DB_ID: ${{ secrets.D1_DATABASE_ID }}
run: sed -i "s/YOUR_D1_DATABASE_ID/$D1_DB_ID/g" wrangler.toml
- name: Build
run: npm run build
- name: Deploy to Cloudflare Pages (production)
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy .svelte-kit/cloudflare --project-name=skyreader-admin --branch=main --commit-dirty=true
workingDirectory: admin