-
Notifications
You must be signed in to change notification settings - Fork 4
100 lines (87 loc) · 2.7 KB
/
deploy.yml
File metadata and controls
100 lines (87 loc) · 2.7 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
name: Deploy to production
on:
workflow_dispatch:
push:
branches:
- main
paths:
- ".github/workflows/deploy.yml"
- "wrangler.toml"
- "frontend/**"
- "crates/**"
- "Cargo.toml"
- "Cargo.lock"
- "rust-toolchain.toml"
jobs:
quality-gate:
uses: ./.github/workflows/quality-gate.yml
with:
checks-command: "--all --check"
clippy-command: "-- -D warnings"
tests-command: "test"
deploy:
needs: [quality-gate]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: pnpm/action-setup@v4
with:
version: 9
- name: Deploy
uses: cloudflare/wrangler-action@v3
env:
API_HOST: ${{ secrets.API_HOST }}
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
workingDirectory: "frontend"
wranglerVersion: "4.19.1"
secrets: |
API_HOST
deploy-backend:
needs: [quality-gate]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install nix
uses: nixbuild/nix-quick-install-action@v30
with:
nix_conf: |
keep-env-derivations = true
keep-outputs = true
- name: Restore and save Nix store
uses: nix-community/cache-nix-action@v6
with:
primary-key: nix-${{ runner.os }}-${{ hashFiles('**/*.nix', 'flake.lock') }}
restore-prefixes-first-match: build-${{ runner.os }}-
- name: Build nix
working-directory: crates/backend
run: nix build ../..#backend
- name: Fix up wrangler toml
working-directory: crates/backend
run: |
echo "---- Before"
cat wrangler.toml
cat wrangler.toml | sed 's/main = "build/main = "result/' | sed 's/command = "worker-build --release"/command = "echo dummy build"/' >| wrangler.prod.toml
echo "---- After"
cat wrangler.prod.toml
- name: Deploy
uses: cloudflare/wrangler-action@v3
env:
GH_CLIENT_ID: ${{ secrets.GH_APP_CLIENT_ID }}
GH_CLIENT_SECRET: ${{ secrets.GH_APP_CLIENT_SECRET }}
ADMINS: ${{ secrets.ADMINS }}
HOST: ${{ secrets.API_HOST }}
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: deploy -c wrangler.prod.toml
workingDirectory: "crates/backend"
wranglerVersion: "4.19.1"
secrets: |
GH_CLIENT_ID
GH_CLIENT_SECRET
ADMINS
HOST