mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-15 12:41:37 +03:00
ci: deploy dev workers in anomaly-dev (#63379)
This commit is contained in:
@@ -12,6 +12,10 @@ set +x
|
||||
|
||||
url=${CLOUDFLARE_TOKEN_URL:-https://kjivkui2evldapbok5fhrrl6oy0fctkp.lambda-url.us-east-1.on.aws/}
|
||||
account=${CLOUDFLARE_ACCOUNT_ID:-15d29c8639fd3733b1b5486a2acfd968}
|
||||
if [[ $# == 1 ]]; then
|
||||
. "$(dirname "$0")/lib.sh"
|
||||
account=$(stage_account "$1")
|
||||
fi
|
||||
|
||||
# One argv value, never a line in curl's config: a newline in an override must not be able to
|
||||
# inject curl options or move the AWS credentials into Basic auth.
|
||||
|
||||
@@ -32,7 +32,8 @@ done
|
||||
|
||||
: "${CLOUDFLARE_API_TOKEN:?Set CLOUDFLARE_API_TOKEN}"
|
||||
# Pinned in targets/ and in the token issuer's config (anomalyco/secrets).
|
||||
export CLOUDFLARE_ACCOUNT_ID=15d29c8639fd3733b1b5486a2acfd968
|
||||
CLOUDFLARE_ACCOUNT_ID=$(stage_account "$mode")
|
||||
export CLOUDFLARE_ACCOUNT_ID
|
||||
|
||||
unexpected=$(cd "$src" && find . ! -type d ! -type f -o -type f ! -path ./SHA256SUMS \
|
||||
! -path ./v0/config.json \
|
||||
|
||||
@@ -24,7 +24,8 @@ target="$release/targets/files/$mode/wrangler.json"
|
||||
|
||||
: "${CLOUDFLARE_API_TOKEN:?Set CLOUDFLARE_API_TOKEN}"
|
||||
# Pinned in targets/ and in the token issuer's config (anomalyco/secrets).
|
||||
export CLOUDFLARE_ACCOUNT_ID=15d29c8639fd3733b1b5486a2acfd968
|
||||
CLOUDFLARE_ACCOUNT_ID=$(stage_account "$mode")
|
||||
export CLOUDFLARE_ACCOUNT_ID
|
||||
|
||||
unexpected=$(cd "$src" && find . ! -type d ! -type f -o -type f ! -path ./SHA256SUMS ! -path ./index.js)
|
||||
[ -z "$unexpected" ] || die "Unexpected files in the files artifact: $unexpected"
|
||||
|
||||
@@ -24,7 +24,8 @@ target="$release/targets/legacy/$mode"
|
||||
|
||||
: "${CLOUDFLARE_API_TOKEN:?Set CLOUDFLARE_API_TOKEN}"
|
||||
# Pinned in targets/ and in the token issuer's config (anomalyco/secrets).
|
||||
export CLOUDFLARE_ACCOUNT_ID=15d29c8639fd3733b1b5486a2acfd968
|
||||
CLOUDFLARE_ACCOUNT_ID=$(stage_account "$mode")
|
||||
export CLOUDFLARE_ACCOUNT_ID
|
||||
|
||||
unexpected=$(cd "$src" && find . ! -type d ! -type f -o -type f ! -path ./SHA256SUMS \
|
||||
! -path ./v0/config.json \
|
||||
|
||||
@@ -24,7 +24,8 @@ target="$release/targets/site/$mode"
|
||||
|
||||
: "${CLOUDFLARE_API_TOKEN:?Set CLOUDFLARE_API_TOKEN}"
|
||||
# Pinned in targets/ and in the token issuer's config (anomalyco/secrets).
|
||||
export CLOUDFLARE_ACCOUNT_ID=15d29c8639fd3733b1b5486a2acfd968
|
||||
CLOUDFLARE_ACCOUNT_ID=$(stage_account "$mode")
|
||||
export CLOUDFLARE_ACCOUNT_ID
|
||||
|
||||
unexpected=$(cd "$src" && find . ! -type d ! -type f -o -type f ! -path ./SHA256SUMS \
|
||||
! -path ./v0/config.json \
|
||||
|
||||
@@ -23,6 +23,14 @@ dry_run() {
|
||||
[ "${OPENCODE_DRY_RUN:-false}" = true ]
|
||||
}
|
||||
|
||||
stage_account() {
|
||||
case "$1" in
|
||||
dev) echo d8e944f537ceef3f06a5bd3aec1d7a53 ;;
|
||||
production) echo 15d29c8639fd3733b1b5486a2acfd968 ;;
|
||||
*) die "Unknown Cloudflare stage: $1" ;;
|
||||
esac
|
||||
}
|
||||
|
||||
sha256() {
|
||||
if command -v sha256sum > /dev/null; then sha256sum "$@"; else shasum -a 256 "$@"; fi
|
||||
}
|
||||
|
||||
@@ -3,25 +3,25 @@
|
||||
"compatibilityDate": "2026-07-25",
|
||||
"compatibilityFlags": ["nodejs_compat"],
|
||||
"triggers": [
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/en/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/zh/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/zht/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/ko/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/de/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/es/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/fr/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/it/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/da/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/ja/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/pl/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/ru/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/uk/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/ar/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/no/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/br/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/th/data*", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/tr/data*", "zone": "opencode.ai" }
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/en/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/zh/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/zht/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/ko/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/de/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/es/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/fr/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/it/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/da/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/ja/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/pl/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/ru/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/uk/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/ar/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/no/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/br/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/th/data*", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/tr/data*", "zone": "dev.opencode.ai" }
|
||||
],
|
||||
"observability": { "enabled": true },
|
||||
"workersDev": false,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"accountId": "15d29c8639fd3733b1b5486a2acfd968",
|
||||
"accountId": "d8e944f537ceef3f06a5bd3aec1d7a53",
|
||||
"buildContext": { "isPreview": false, "mode": "dev" }
|
||||
}
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
{
|
||||
"name": "opencode-dev-files",
|
||||
"account_id": "d8e944f537ceef3f06a5bd3aec1d7a53",
|
||||
"main": "index.js",
|
||||
"no_bundle": true,
|
||||
"compatibility_date": "2026-08-01",
|
||||
"workers_dev": false,
|
||||
"preview_urls": false,
|
||||
"vars": { "STAGE": "dev" },
|
||||
"routes": [{ "pattern": "dev.opencode.ai/files/*", "zone_name": "opencode.ai" }],
|
||||
"routes": [{ "pattern": "dev.opencode.ai/files/*", "zone_name": "dev.opencode.ai" }],
|
||||
"r2_buckets": [{ "binding": "FILES", "bucket_name": "opencode-dev-files" }]
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"accountId": "15d29c8639fd3733b1b5486a2acfd968",
|
||||
"accountId": "d8e944f537ceef3f06a5bd3aec1d7a53",
|
||||
"buildContext": { "isPreview": false, "mode": "dev" }
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"compatibilityDate": "2026-07-25",
|
||||
"compatibilityFlags": ["nodejs_compat"],
|
||||
"domains": ["dev.opncd.ai", "api.dev.opencode.ai"],
|
||||
"logpush": true,
|
||||
"logpush": false,
|
||||
"observability": { "enabled": true },
|
||||
"workersDev": false,
|
||||
"previewUrls": false,
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
"accountId": "15d29c8639fd3733b1b5486a2acfd968",
|
||||
"accountId": "d8e944f537ceef3f06a5bd3aec1d7a53",
|
||||
"buildContext": { "isPreview": false, "mode": "dev" }
|
||||
}
|
||||
|
||||
@@ -24,8 +24,8 @@
|
||||
},
|
||||
"domains": ["dev.opencode.ai", "docs.dev.opencode.ai"],
|
||||
"triggers": [
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai", "zone": "opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/*", "zone": "opencode.ai" }
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai", "zone": "dev.opencode.ai" },
|
||||
{ "type": "fetch", "pattern": "dev.opencode.ai/*", "zone": "dev.opencode.ai" }
|
||||
],
|
||||
"observability": { "enabled": true },
|
||||
"workersDev": false,
|
||||
|
||||
@@ -106,7 +106,7 @@ jobs:
|
||||
# It is a step output, so only the Deploy step gets it.
|
||||
- name: Cloudflare token
|
||||
id: cloudflare-token
|
||||
run: bash .github/release/cloudflare-token.sh
|
||||
run: bash .github/release/cloudflare-token.sh "$GITHUB_REF_NAME"
|
||||
env:
|
||||
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ jobs:
|
||||
# It is a step output, so only the Deploy step gets it.
|
||||
- name: Cloudflare token
|
||||
id: cloudflare-token
|
||||
run: bash .github/release/cloudflare-token.sh
|
||||
run: bash .github/release/cloudflare-token.sh "$GITHUB_REF_NAME"
|
||||
env:
|
||||
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ jobs:
|
||||
# It is a step output, so only the Deploy step gets it.
|
||||
- name: Cloudflare token
|
||||
id: cloudflare-token
|
||||
run: bash .github/release/cloudflare-token.sh
|
||||
run: bash .github/release/cloudflare-token.sh "$GITHUB_REF_NAME"
|
||||
env:
|
||||
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
|
||||
|
||||
@@ -185,7 +185,7 @@ jobs:
|
||||
|
||||
- name: Cloudflare token
|
||||
id: cloudflare-token
|
||||
run: bash .github/release/cloudflare-token.sh
|
||||
run: bash .github/release/cloudflare-token.sh "$GITHUB_REF_NAME"
|
||||
env:
|
||||
CLOUDFLARE_TOKEN_URL: ${{ vars.CLOUDFLARE_TOKEN_URL }}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { bindings, defineConfig, triggers } from "cf/config"
|
||||
import { LOCALES } from "../../packages/data/app/src/lib/language"
|
||||
import { ogWorkerName } from "./og.config"
|
||||
import { stage, stageHost } from "./stage"
|
||||
import { stage, stageAccount, stageHost } from "./stage"
|
||||
|
||||
// The data site (packages/data/app, SolidStart) at /data and /<locale>/data on the main host. `--mode dev` deploys
|
||||
// opencode-data-dev on dev.opencode.ai and `--mode production` opencode-data-production on opencode.ai; any other
|
||||
@@ -14,7 +14,7 @@ export default defineConfig(({ mode }) => {
|
||||
const host = stageHost(current)
|
||||
return {
|
||||
// Anomaly
|
||||
accountId: "15d29c8639fd3733b1b5486a2acfd968",
|
||||
accountId: stageAccount(current),
|
||||
worker: {
|
||||
name: `opencode-data-${current}`,
|
||||
compatibilityDate: "2026-07-25",
|
||||
@@ -33,7 +33,7 @@ export default defineConfig(({ mode }) => {
|
||||
DATA_DATABASE_PASSWORD: bindings.secret(),
|
||||
},
|
||||
triggers: ["data", ...LOCALES.map((locale) => `${locale}/data`)].map((prefix) =>
|
||||
triggers.fetch({ pattern: `${host}/${prefix}*`, zone: "opencode.ai" }),
|
||||
triggers.fetch({ pattern: `${host}/${prefix}*`, zone: host }),
|
||||
),
|
||||
workersDev: false,
|
||||
previewUrls: false,
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { defineConfig } from "cf/config"
|
||||
import { stage } from "./stage"
|
||||
import { stage, stageAccount } from "./stage"
|
||||
|
||||
export const ogWorkerName = (mode: string | undefined) => `opencode-data-og-${stage(mode)}`
|
||||
|
||||
@@ -8,7 +8,7 @@ export const ogWorkerName = (mode: string | undefined) => `opencode-data-og-${st
|
||||
// Worker doesn't load the Wasm engines and fonts it ships as modules (script/build.ts).
|
||||
export default defineConfig(({ mode }) => ({
|
||||
// Anomaly
|
||||
accountId: "15d29c8639fd3733b1b5486a2acfd968",
|
||||
accountId: stageAccount(stage(mode)),
|
||||
worker: {
|
||||
name: ogWorkerName(mode),
|
||||
compatibilityDate: "2026-07-01",
|
||||
|
||||
@@ -16,3 +16,7 @@ export function stage(mode: string | undefined): Stage {
|
||||
export function stageHost(value: Stage) {
|
||||
return hosts[value]
|
||||
}
|
||||
|
||||
export function stageAccount(value: Stage) {
|
||||
return value === "dev" ? "d8e944f537ceef3f06a5bd3aec1d7a53" : "15d29c8639fd3733b1b5486a2acfd968"
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { bindings, defineConfig, exports, triggers } from "cf/config"
|
||||
import { stage } from "./stage"
|
||||
import { stage, stageAccount } from "./stage"
|
||||
|
||||
// The Worker that syncs R2 SQL aggregates into the data database (packages/data/server/src/worker.ts): the
|
||||
// DataSyncWorkflow, and the cron handler that starts its runs. The schedules must match
|
||||
@@ -9,7 +9,7 @@ export default defineConfig(({ mode }) => {
|
||||
const name = `opencode-data-sync-${current}`
|
||||
return {
|
||||
// Anomaly
|
||||
accountId: "15d29c8639fd3733b1b5486a2acfd968",
|
||||
accountId: stageAccount(current),
|
||||
worker: {
|
||||
name,
|
||||
compatibilityDate: "2026-07-25",
|
||||
|
||||
@@ -8,8 +8,9 @@
|
||||
"env": {
|
||||
"dev": {
|
||||
"name": "opencode-dev-files",
|
||||
"account_id": "d8e944f537ceef3f06a5bd3aec1d7a53",
|
||||
"vars": { "STAGE": "dev" },
|
||||
"routes": [{ "pattern": "dev.opencode.ai/files/*", "zone_name": "opencode.ai" }],
|
||||
"routes": [{ "pattern": "dev.opencode.ai/files/*", "zone_name": "dev.opencode.ai" }],
|
||||
"r2_buckets": [{ "binding": "FILES", "bucket_name": "opencode-dev-files" }],
|
||||
},
|
||||
"production": {
|
||||
|
||||
@@ -9,7 +9,7 @@ export default defineConfig(({ mode }) => {
|
||||
const dev = mode === "dev"
|
||||
return {
|
||||
// Anomaly
|
||||
accountId: "15d29c8639fd3733b1b5486a2acfd968",
|
||||
accountId: dev ? "d8e944f537ceef3f06a5bd3aec1d7a53" : "15d29c8639fd3733b1b5486a2acfd968",
|
||||
worker: {
|
||||
name: dev ? "opencode-legacy-dev" : "opencode-legacy-production",
|
||||
compatibilityDate: "2026-07-25",
|
||||
@@ -24,7 +24,7 @@ export default defineConfig(({ mode }) => {
|
||||
},
|
||||
workersDev: false,
|
||||
previewUrls: false,
|
||||
logpush: true,
|
||||
logpush: !dev,
|
||||
observability: { enabled: true },
|
||||
},
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ export default defineConfig(({ mode }) => {
|
||||
const host = dev ? "dev.opencode.ai" : "opencode.ai"
|
||||
return {
|
||||
// Anomaly
|
||||
accountId: "15d29c8639fd3733b1b5486a2acfd968",
|
||||
accountId: dev ? "d8e944f537ceef3f06a5bd3aec1d7a53" : "15d29c8639fd3733b1b5486a2acfd968",
|
||||
worker: {
|
||||
name: dev ? "opencode-site-dev" : "opencode-site-production",
|
||||
compatibilityDate: "2026-07-25",
|
||||
@@ -39,8 +39,8 @@ export default defineConfig(({ mode }) => {
|
||||
triggers:
|
||||
dev || productionOwnsRoot
|
||||
? [
|
||||
triggers.fetch({ pattern: host, zone: "opencode.ai" }),
|
||||
triggers.fetch({ pattern: `${host}/*`, zone: "opencode.ai" }),
|
||||
triggers.fetch({ pattern: host, zone: host }),
|
||||
triggers.fetch({ pattern: `${host}/*`, zone: host }),
|
||||
]
|
||||
: [],
|
||||
// The bare host is a custom domain (it also supplies the DNS record), and cf detaches any domain
|
||||
|
||||
Reference in New Issue
Block a user