-
Notifications
You must be signed in to change notification settings - Fork 24
159 lines (143 loc) · 5.13 KB
/
deploy-workers.yml
File metadata and controls
159 lines (143 loc) · 5.13 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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
name: Deploy Cloudflare Workers
on:
push:
branches: [main]
workflow_dispatch:
inputs:
worker:
description: 'Worker folder to deploy (e.g. cloudflare-app-builder)'
required: true
type: choice
options:
- cloud-agent
- cloud-agent-next
- cloudflare-ai-attribution
- cloudflare-app-builder
- cloudflare-auto-fix-infra
- cloudflare-auto-triage-infra
- cloudflare-code-review-infra
- cloudflare-db-proxy
- cloudflare-deploy-infra/builder
- cloudflare-deploy-infra/dispatcher
- cloudflare-gastown
- cloudflare-git-token-service
- cloudflare-gmail-push
- cloudflare-images-mcp
- cloudflare-o11y
- cloudflare-security-auto-analysis
- cloudflare-security-sync
- cloudflare-session-ingest
- cloudflare-webhook-agent-ingest
concurrency:
group: deploy-workers-${{ github.ref }}
cancel-in-progress: false
jobs:
# ── Manual dispatch: deploy a single specified worker ──────────────────────
deploy-manual:
if: github.event_name == 'workflow_dispatch'
runs-on: ${{ vars.RUNNER_DEFAULT_LABEL || 'ubuntu-latest' }}
name: Deploy ${{ inputs.worker }}
steps:
- name: Checkout code
uses: useblacksmith/checkout@v1
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
working-directory: ${{ inputs.worker }}
run: pnpm install --frozen-lockfile
- name: Deploy to Cloudflare Workers
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
workingDirectory: ${{ inputs.worker }}
command: deploy
# ── Push to main: detect changed workers, deploy each one ─────────────────
detect-changes:
if: github.event_name == 'push'
runs-on: ${{ vars.RUNNER_DEFAULT_LABEL || 'ubuntu-latest' }}
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout code
uses: useblacksmith/checkout@v1
with:
fetch-depth: 0
- name: Find changed workers
id: set-matrix
run: |
# All deployable workers (folders containing wrangler.jsonc).
# kiloclaw is excluded — it has a custom Docker-based deploy in deploy-production.yml.
# builder-docker-container is excluded — it is a build artifact, not a deployable worker.
#
# Diff against the SHA before the push so that multi-commit pushes
# (e.g. a merge commit that squashes several commits) don't miss workers
# that were only touched in earlier commits of the same push.
BASE_SHA="${{ github.event.before }}"
WORKERS=(
cloud-agent
cloud-agent-next
cloudflare-ai-attribution
cloudflare-app-builder
cloudflare-auto-fix-infra
cloudflare-auto-triage-infra
cloudflare-code-review-infra
cloudflare-db-proxy
cloudflare-deploy-infra/builder
cloudflare-deploy-infra/dispatcher
cloudflare-gastown
cloudflare-git-token-service
cloudflare-gmail-push
cloudflare-images-mcp
cloudflare-o11y
cloudflare-security-auto-analysis
cloudflare-security-sync
cloudflare-session-ingest
cloudflare-webhook-agent-ingest
)
CHANGED=()
for dir in "${WORKERS[@]}"; do
if git diff --name-only "$BASE_SHA" HEAD -- "$dir/" | grep -q .; then
CHANGED+=("$dir")
fi
done
if [ ${#CHANGED[@]} -eq 0 ]; then
echo "matrix=[]" >> "$GITHUB_OUTPUT"
else
MATRIX=$(printf '%s\n' "${CHANGED[@]}" | jq -R . | jq -sc .)
echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT"
fi
deploy-changed:
needs: detect-changes
if: needs.detect-changes.outputs.matrix != '[]' && needs.detect-changes.outputs.matrix != ''
runs-on: ${{ vars.RUNNER_DEFAULT_LABEL || 'ubuntu-latest' }}
strategy:
fail-fast: false
matrix:
worker: ${{ fromJson(needs.detect-changes.outputs.matrix) }}
name: Deploy ${{ matrix.worker }}
steps:
- name: Checkout code
uses: useblacksmith/checkout@v1
- name: Setup pnpm
uses: pnpm/action-setup@v2
with:
version: latest
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 22
- name: Install dependencies
working-directory: ${{ matrix.worker }}
run: pnpm install --frozen-lockfile
- name: Deploy to Cloudflare Workers
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
workingDirectory: ${{ matrix.worker }}
command: deploy