History

Add production deploy workflow (#1295)

Rhys Sullivan committed 4 months ago

Commit dfac2871 parent 51cfd6c1 file · +120 −0Browse files

Unified · Split

.github/workflows/deploy.yml+120−0
@@ -0,0 +1,120 @@
1+name: Deploy
2+
3+on:
4+ push:
5+ branches: [main]
6+ workflow_dispatch:
7+
8+concurrency:
9+ group: deploy-production
10+ cancel-in-progress: false
11+
12+jobs:
13+ migrate:
14+ name: Migrate database
15+ runs-on: blacksmith-4vcpu-ubuntu-2404
16+ environment: production
17+ steps:
18+ - uses: actions/checkout@v4
19+
20+ - uses: oven-sh/setup-bun@v2
21+ with:
22+ bun-version: 1.3.11
23+
24+ - name: Cache Bun package cache
25+ uses: actions/cache@v4
26+ with:
27+ path: ~/.bun/install/cache
28+ key: ${{ runner.os }}-bun-1.3.11-${{ hashFiles('bun.lock') }}
29+ restore-keys: |
30+ ${{ runner.os }}-bun-1.3.11-
31+
32+ - uses: actions/setup-node@v4
33+ with:
34+ node-version: 22
35+
36+ - name: Install dependencies
37+ run: bun install --frozen-lockfile
38+
39+ - name: Run migrations
40+ run: bun run scripts/migrate.ts --bucket executor-cloud-blobs
41+ working-directory: apps/cloud
42+ env:
43+ DATABASE_URL: ${{ secrets.DATABASE_URL }}
44+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
45+ CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
46+
47+ deploy-cloud:
48+ name: Deploy cloud
49+ runs-on: blacksmith-4vcpu-ubuntu-2404
50+ environment: production
51+ needs: migrate
52+ steps:
53+ - uses: actions/checkout@v4
54+
55+ - uses: oven-sh/setup-bun@v2
56+ with:
57+ bun-version: 1.3.11
58+
59+ - name: Cache Bun package cache
60+ uses: actions/cache@v4
61+ with:
62+ path: ~/.bun/install/cache
63+ key: ${{ runner.os }}-bun-1.3.11-${{ hashFiles('bun.lock') }}
64+ restore-keys: |
65+ ${{ runner.os }}-bun-1.3.11-
66+
67+ - uses: actions/setup-node@v4
68+ with:
69+ node-version: 22
70+
71+ - name: Install dependencies
72+ run: bun install --frozen-lockfile
73+
74+ - name: Build cloud
75+ run: bun run --cwd apps/cloud build
76+ env:
77+ VITE_PUBLIC_SENTRY_DSN: ${{ secrets.VITE_PUBLIC_SENTRY_DSN }}
78+
79+ - name: Deploy cloud
80+ run: bun run wrangler deploy -c dist/server/wrangler.json
81+ working-directory: apps/cloud
82+ env:
83+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
84+ CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
85+
86+ deploy-marketing:
87+ name: Deploy marketing
88+ runs-on: blacksmith-4vcpu-ubuntu-2404
89+ environment: production
90+ steps:
91+ - uses: actions/checkout@v4
92+
93+ - uses: oven-sh/setup-bun@v2
94+ with:
95+ bun-version: 1.3.11
96+
97+ - name: Cache Bun package cache
98+ uses: actions/cache@v4
99+ with:
100+ path: ~/.bun/install/cache
101+ key: ${{ runner.os }}-bun-1.3.11-${{ hashFiles('bun.lock') }}
102+ restore-keys: |
103+ ${{ runner.os }}-bun-1.3.11-
104+
105+ - uses: actions/setup-node@v4
106+ with:
107+ node-version: 22
108+
109+ - name: Install dependencies
110+ run: bun install --frozen-lockfile
111+
112+ - name: Build marketing
113+ run: bun run --cwd apps/marketing build
114+
115+ - name: Deploy marketing
116+ run: bun run wrangler deploy --config dist/server/wrangler.json
117+ working-directory: apps/marketing
118+ env:
119+ CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
120+ CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}