Skip to content

Commit 9d30dd8

Browse files
Merge pull request #83 from richardthe3rd/claude/split-cloudflare-workflow-01NenxgqTYjiWnPVknJsHnh6
Separate Cloudflare Workers workflow into own file
2 parents 87a17d9 + 43e097f commit 9d30dd8

5 files changed

Lines changed: 865 additions & 121 deletions

File tree

.github/workflows/build-deploy.yml

Lines changed: 7 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build and Deploy
1+
name: Flutter App CI/CD
22

33
on:
44
push:
@@ -24,8 +24,6 @@ jobs:
2424
runs-on: ubuntu-latest
2525
outputs:
2626
app: ${{ steps.filter.outputs.app }}
27-
worker: ${{ steps.filter.outputs.worker }}
28-
festivals: ${{ steps.filter.outputs.festivals }}
2927
steps:
3028
- name: Checkout
3129
uses: actions/checkout@v4
@@ -43,70 +41,14 @@ jobs:
4341
- 'android/**'
4442
- '.github/workflows/build-deploy.yml'
4543
- 'mise.toml'
46-
worker:
47-
- 'cloudflare-worker/**'
48-
festivals:
49-
- 'data/festivals.json'
50-
51-
# Validate festivals.json against schema
52-
validate-festivals:
53-
needs: changes
54-
runs-on: ubuntu-latest
55-
if: needs.changes.outputs.festivals == 'true'
56-
steps:
57-
- name: Checkout
58-
uses: actions/checkout@v4
59-
60-
- name: Setup Node.js
61-
uses: actions/setup-node@v4
62-
with:
63-
node-version: '20'
64-
cache: 'npm'
65-
cache-dependency-path: scripts/package-lock.json
66-
67-
- name: Install validation dependencies
68-
working-directory: scripts
69-
run: npm ci
70-
71-
- name: Validate festivals.json
72-
run: node scripts/validate-festivals.js
73-
74-
# Validate Cloudflare Worker on PRs (dry-run)
75-
validate-worker:
76-
needs: changes
77-
runs-on: ubuntu-latest
78-
if: |
79-
github.event_name == 'pull_request' &&
80-
(needs.changes.outputs.worker == 'true' || needs.changes.outputs.festivals == 'true')
81-
steps:
82-
- name: Checkout
83-
uses: actions/checkout@v4
84-
85-
- name: Setup Node.js
86-
uses: actions/setup-node@v4
87-
with:
88-
node-version: '20'
89-
90-
- name: Install worker dependencies
91-
working-directory: cloudflare-worker
92-
run: npm ci
93-
94-
- name: Copy festivals.json to worker directory
95-
run: cp data/festivals.json cloudflare-worker/festivals.json
96-
97-
- name: Validate worker (dry-run)
98-
uses: cloudflare/wrangler-action@v3
99-
with:
100-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
101-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
102-
workingDirectory: cloudflare-worker
103-
command: deploy --dry-run
10444
10545
# Run tests once before building
10646
test:
10747
needs: changes
10848
runs-on: ubuntu-latest
109-
if: needs.changes.outputs.app == 'true'
49+
if: |
50+
github.event_name == 'workflow_dispatch' ||
51+
needs.changes.outputs.app == 'true'
11052
steps:
11153
- name: Checkout
11254
uses: actions/checkout@v4
@@ -240,41 +182,6 @@ jobs:
240182
path: build/app/outputs/bundle/release/app-release.aab
241183
if-no-files-found: error
242184

243-
deploy-worker:
244-
needs: changes
245-
runs-on: ubuntu-latest
246-
if: |
247-
github.ref == 'refs/heads/main' &&
248-
(needs.changes.outputs.worker == 'true' || needs.changes.outputs.festivals == 'true')
249-
steps:
250-
- name: Checkout
251-
uses: actions/checkout@v4
252-
253-
- name: Setup Node.js
254-
uses: actions/setup-node@v4
255-
with:
256-
node-version: '20'
257-
258-
- name: Validate festivals.json
259-
if: needs.changes.outputs.festivals == 'true'
260-
run: |
261-
cd scripts && npm ci
262-
node validate-festivals.js
263-
264-
- name: Install worker dependencies
265-
working-directory: cloudflare-worker
266-
run: npm ci
267-
268-
- name: Copy festivals.json to worker directory
269-
run: cp data/festivals.json cloudflare-worker/festivals.json
270-
271-
- name: Deploy Cloudflare Worker
272-
uses: cloudflare/wrangler-action@v3
273-
with:
274-
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
275-
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
276-
workingDirectory: cloudflare-worker
277-
278185
deploy-web:
279186
needs: build-web
280187
runs-on: ubuntu-latest
@@ -304,7 +211,9 @@ jobs:
304211
deploy-web-preview:
305212
needs: [changes, build-web]
306213
runs-on: ubuntu-latest
307-
if: needs.changes.outputs.app == 'true'
214+
if: |
215+
github.event_name == 'workflow_dispatch' ||
216+
needs.changes.outputs.app == 'true'
308217
steps:
309218
- name: Download build artifact
310219
uses: actions/download-artifact@v4
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
name: Cloudflare Worker
2+
3+
on:
4+
push:
5+
branches: [main]
6+
paths:
7+
- 'cloudflare-worker/**'
8+
- 'data/festivals.json'
9+
- '.github/workflows/cloudflare-worker.yml'
10+
pull_request:
11+
branches: [main]
12+
paths:
13+
- 'cloudflare-worker/**'
14+
- 'data/festivals.json'
15+
- '.github/workflows/cloudflare-worker.yml'
16+
workflow_dispatch:
17+
18+
permissions:
19+
contents: read
20+
pull-requests: write
21+
22+
concurrency:
23+
group: cloudflare-worker-${{ github.ref }}
24+
cancel-in-progress: ${{ github.ref != 'refs/heads/main' }}
25+
26+
jobs:
27+
# Detect which files have changed
28+
changes:
29+
runs-on: ubuntu-latest
30+
outputs:
31+
worker: ${{ steps.filter.outputs.worker }}
32+
festivals: ${{ steps.filter.outputs.festivals }}
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v4
36+
37+
- name: Check for file changes
38+
uses: dorny/paths-filter@v3
39+
id: filter
40+
with:
41+
filters: |
42+
worker:
43+
- 'cloudflare-worker/**'
44+
festivals:
45+
- 'data/festivals.json'
46+
47+
# Validate festivals.json against schema
48+
validate-festivals:
49+
needs: changes
50+
runs-on: ubuntu-latest
51+
if: |
52+
github.event_name == 'workflow_dispatch' ||
53+
needs.changes.outputs.festivals == 'true'
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v4
57+
58+
- name: Setup Node.js
59+
uses: actions/setup-node@v4
60+
with:
61+
node-version: '20'
62+
cache: 'npm'
63+
cache-dependency-path: scripts/package-lock.json
64+
65+
- name: Install validation dependencies
66+
working-directory: scripts
67+
run: npm ci
68+
69+
- name: Validate festivals.json
70+
run: node scripts/validate-festivals.js
71+
72+
# Validate Cloudflare Worker on PRs (dry-run)
73+
validate-worker:
74+
needs: changes
75+
runs-on: ubuntu-latest
76+
if: |
77+
github.event_name == 'pull_request' &&
78+
(needs.changes.outputs.worker == 'true' || needs.changes.outputs.festivals == 'true')
79+
steps:
80+
- name: Checkout
81+
uses: actions/checkout@v4
82+
83+
- name: Setup Node.js
84+
uses: actions/setup-node@v4
85+
with:
86+
node-version: '20'
87+
88+
- name: Install worker dependencies
89+
working-directory: cloudflare-worker
90+
run: npm ci
91+
92+
- name: Copy festivals.json to worker directory
93+
run: cp data/festivals.json cloudflare-worker/festivals.json
94+
95+
- name: Validate worker (dry-run)
96+
uses: cloudflare/wrangler-action@v3
97+
with:
98+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
99+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
100+
workingDirectory: cloudflare-worker
101+
command: deploy --dry-run
102+
103+
# Deploy Cloudflare Worker to production
104+
deploy-worker:
105+
needs: changes
106+
runs-on: ubuntu-latest
107+
if: |
108+
github.ref == 'refs/heads/main' &&
109+
(github.event_name == 'workflow_dispatch' ||
110+
needs.changes.outputs.worker == 'true' ||
111+
needs.changes.outputs.festivals == 'true')
112+
steps:
113+
- name: Checkout
114+
uses: actions/checkout@v4
115+
116+
- name: Setup Node.js
117+
uses: actions/setup-node@v4
118+
with:
119+
node-version: '20'
120+
121+
- name: Validate festivals.json
122+
if: |
123+
github.event_name == 'workflow_dispatch' ||
124+
needs.changes.outputs.festivals == 'true'
125+
run: |
126+
cd scripts && npm ci
127+
node validate-festivals.js
128+
129+
- name: Install worker dependencies
130+
working-directory: cloudflare-worker
131+
run: npm ci
132+
133+
- name: Copy festivals.json to worker directory
134+
run: cp data/festivals.json cloudflare-worker/festivals.json
135+
136+
- name: Deploy Cloudflare Worker
137+
uses: cloudflare/wrangler-action@v3
138+
with:
139+
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
140+
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
141+
workingDirectory: cloudflare-worker

0 commit comments

Comments
 (0)