Skip to content

Deploy Cloudflare

Deploy Cloudflare #89

name: Deploy Cloudflare
on:
workflow_dispatch:
concurrency:
group: deploy-cloudflare-production
cancel-in-progress: false
permissions:
actions: read
contents: read
jobs:
deploy:
name: Deploy Workers
runs-on: ubuntu-24.04
timeout-minutes: 45
environment: Production
steps:
- name: Require main
run: test "$GITHUB_REF" = "refs/heads/main"
- name: Require successful static checks for this commit
env:
GH_TOKEN: ${{ github.token }}
run: |
successful_runs="$(gh api --method GET \
"repos/${GITHUB_REPOSITORY}/actions/workflows/static-checks.yml/runs" \
--field branch=main \
--field event=push \
--field head_sha="$GITHUB_SHA" \
--field per_page=1 \
--field status=success \
--jq '.total_count')"
if [ "$successful_runs" -lt 1 ]; then
echo "Static Checks has not succeeded for $GITHUB_SHA on main." >&2
exit 1
fi
- name: Checkout reviewed release
uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6.1.0
with:
ref: ${{ github.sha }}
- uses: ./.github/actions/setup-repository
with:
release-sha: ${{ github.sha }}
- name: Build Worker release
run: >-
pnpm exec turbo run build
--filter=@cheatcode/agent-worker
--filter=@cheatcode/webhooks-worker
--filter=@cheatcode/gateway-worker
--filter=@cheatcode/preview-proxy
- name: Deploy Workers
run: |
set -Eeuo pipefail
configs=(
apps/agent-worker/wrangler.jsonc
apps/webhooks-worker/wrangler.jsonc
apps/preview-proxy/wrangler.jsonc
apps/gateway-worker/wrangler.jsonc
)
for config in "${configs[@]}"; do
pnpm exec wrangler deploy \
--config "$config" \
--var "CHEATCODE_RELEASE_SHA:$GITHUB_SHA"
done
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}