-
-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (71 loc) · 2.36 KB
/
Copy pathdeploy-api.yml
File metadata and controls
85 lines (71 loc) · 2.36 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
name: Deploy API
on:
push:
branches: [main]
paths:
- 'packages/api/**'
- '.github/workflows/deploy-api.yml'
workflow_dispatch:
inputs:
environment:
description: 'Deploy environment'
required: true
default: 'production'
type: choice
options:
- staging
- production
# Minimum-privilege default. The Cloudflare deploy doesn't push commits
# or create issues; checkout + read of the workflow definition is all
# the GITHUB_TOKEN side needs. Wrangler authenticates via the
# CLOUDFLARE_API_TOKEN secret separately.
permissions:
contents: read
jobs:
test:
name: Test API
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v5
with:
node-version: '22'
cache: 'pnpm'
# Install only the API workspace and its transitive deps. The full
# `pnpm install` would also run apps/desktop's postinstall (electron-builder
# install-app-deps -> better-sqlite3 native rebuild), which fails on the
# Linux + Node 22 runner against current Electron headers. The API worker
# has no need for any of that.
- run: pnpm install --filter '@dripnex/api...' --ignore-scripts
- name: Typecheck
run: pnpm --filter @dripnex/api typecheck
- name: Test
run: pnpm --filter @dripnex/api test
deploy:
name: Deploy API
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: pnpm/action-setup@v5
- uses: actions/setup-node@v5
with:
node-version: '22'
cache: 'pnpm'
- run: pnpm install --filter '@dripnex/api...' --ignore-scripts
- name: Determine environment
id: env
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "target=${{ inputs.environment }}" >> "$GITHUB_OUTPUT"
else
echo "target=production" >> "$GITHUB_OUTPUT"
fi
- name: Deploy to Cloudflare Workers
env:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
DEPLOY_ENV: ${{ steps.env.outputs.target }}
run: npx wrangler deploy --env "$DEPLOY_ENV"
working-directory: packages/api