Skip to content

Commit 945fbc2

Browse files
committed
Add Cloudflare frontend deploy workflows
1 parent 067c66b commit 945fbc2

10 files changed

Lines changed: 1400 additions & 39 deletions

File tree

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
name: Frontend Cloudflare Deploy
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
push:
8+
branches:
9+
- dev
10+
tags:
11+
- frontend-pre-*
12+
- frontend-live-*
13+
workflow_dispatch:
14+
inputs:
15+
product:
16+
description: Product to deploy
17+
required: true
18+
type: choice
19+
default: all
20+
options:
21+
- all
22+
- nucleum
23+
- memotron
24+
- pointron
25+
environment:
26+
description: Frontend environment to deploy
27+
required: true
28+
type: choice
29+
default: dev
30+
options:
31+
- dev
32+
- pre
33+
- live
34+
35+
jobs:
36+
detect:
37+
runs-on: ubuntu-latest
38+
outputs:
39+
environment: ${{ steps.detect.outputs.environment }}
40+
products: ${{ steps.detect.outputs.products }}
41+
steps:
42+
- id: detect
43+
env:
44+
EVENT_NAME: ${{ github.event_name }}
45+
INPUT_ENVIRONMENT: ${{ github.event.inputs.environment }}
46+
INPUT_PRODUCT: ${{ github.event.inputs.product }}
47+
REF_TYPE: ${{ github.ref_type }}
48+
REF_NAME: ${{ github.ref_name }}
49+
run: |
50+
set -euo pipefail
51+
52+
default_products='["nucleum","memotron","pointron"]'
53+
54+
if [ "$EVENT_NAME" = "workflow_dispatch" ]; then
55+
environment="${INPUT_ENVIRONMENT:-dev}"
56+
product="${INPUT_PRODUCT:-all}"
57+
case "$environment" in
58+
pre)
59+
[[ "$REF_TYPE" == "tag" && "$REF_NAME" == frontend-pre-* ]] || {
60+
echo "Pre deploys must run from a frontend-pre-* tag" >&2
61+
exit 1
62+
}
63+
;;
64+
live)
65+
[[ "$REF_TYPE" == "tag" && "$REF_NAME" == frontend-live-* ]] || {
66+
echo "Live deploys must run from a frontend-live-* tag" >&2
67+
exit 1
68+
}
69+
;;
70+
esac
71+
elif [[ "$REF_TYPE" == "tag" && "$REF_NAME" == frontend-pre-* ]]; then
72+
environment="pre"
73+
product="all"
74+
elif [[ "$REF_TYPE" == "tag" && "$REF_NAME" == frontend-live-* ]]; then
75+
environment="live"
76+
product="all"
77+
else
78+
environment="dev"
79+
product="all"
80+
fi
81+
82+
case "$environment" in
83+
dev|pre|live) ;;
84+
*) echo "Invalid environment: $environment" >&2; exit 1 ;;
85+
esac
86+
87+
case "$product" in
88+
all) products="$default_products" ;;
89+
nucleum|memotron|pointron) products="[\"$product\"]" ;;
90+
*) echo "Invalid product: $product" >&2; exit 1 ;;
91+
esac
92+
93+
echo "environment=$environment" >> "$GITHUB_OUTPUT"
94+
echo "products=$products" >> "$GITHUB_OUTPUT"
95+
96+
deploy:
97+
runs-on: ubuntu-latest
98+
needs: detect
99+
environment: ${{ needs.detect.outputs.environment }}
100+
concurrency:
101+
group: frontend-cloudflare-deploy-${{ needs.detect.outputs.environment }}-${{ matrix.product }}
102+
cancel-in-progress: false
103+
strategy:
104+
fail-fast: false
105+
matrix:
106+
product: ${{ fromJson(needs.detect.outputs.products) }}
107+
steps:
108+
- name: Checkout Nucleus
109+
uses: actions/checkout@v4
110+
111+
- name: Setup Node
112+
uses: actions/setup-node@v4
113+
with:
114+
node-version: 22
115+
cache: npm
116+
117+
- name: Install dependencies
118+
run: npm ci --legacy-peer-deps
119+
120+
- name: Validate frontend Cloudflare config
121+
run: npm --workspace @21n/frontend-deploy run check
122+
123+
- name: Deploy frontend Worker assets
124+
env:
125+
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
126+
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
127+
run: npm --workspace @21n/frontend-deploy run deploy:${{ needs.detect.outputs.environment }} -- --products=${{ matrix.product }}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: Frontend Cloudflare Routes
2+
3+
permissions:
4+
contents: read
5+
6+
on:
7+
workflow_dispatch:
8+
inputs:
9+
product:
10+
description: Product routes to sync
11+
required: true
12+
type: choice
13+
default: all
14+
options:
15+
- all
16+
- nucleum
17+
- memotron
18+
- pointron
19+
environment:
20+
description: Frontend route environment
21+
required: true
22+
type: choice
23+
default: dev
24+
options:
25+
- dev
26+
- pre
27+
- live
28+
29+
jobs:
30+
routes:
31+
runs-on: ubuntu-latest
32+
environment: ${{ github.event.inputs.environment }}
33+
concurrency:
34+
group: frontend-cloudflare-routes-${{ github.event.inputs.environment }}
35+
cancel-in-progress: false
36+
steps:
37+
- name: Checkout Nucleus
38+
uses: actions/checkout@v4
39+
40+
- name: Setup Node
41+
uses: actions/setup-node@v4
42+
with:
43+
node-version: 22
44+
cache: npm
45+
46+
- name: Install dependencies
47+
run: npm ci --legacy-peer-deps
48+
49+
- name: Validate frontend Cloudflare config
50+
run: npm --workspace @21n/frontend-deploy run check
51+
52+
- name: Sync frontend routes
53+
env:
54+
CLOUDFLARE_ROUTES_TOKEN: ${{ secrets.CLOUDFLARE_ROUTES_TOKEN || secrets.CLOUDFLARE_API_TOKEN }}
55+
CLOUDFLARE_ZONE_ID_NUCLEUM_APP: ${{ vars.CLOUDFLARE_ZONE_ID_NUCLEUM_APP }}
56+
CLOUDFLARE_ZONE_ID_MEMOTRON_APP: ${{ vars.CLOUDFLARE_ZONE_ID_MEMOTRON_APP }}
57+
CLOUDFLARE_ZONE_ID_POINTRON_APP: ${{ vars.CLOUDFLARE_ZONE_ID_POINTRON_APP }}
58+
run: npm --workspace @21n/frontend-deploy run routes:${{ github.event.inputs.environment }} -- --products=${{ github.event.inputs.product }}

0 commit comments

Comments
 (0)