Skip to content

Commit 9c318ce

Browse files
committed
chore: move the api worker into the legacy service
1 parent 7b830a4 commit 9c318ce

22 files changed

Lines changed: 183 additions & 233 deletions

‎.github/workflows/deploy.yml‎

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ jobs:
6161
VITE_SENTRY_DSN: ${{ vars.WEB_SENTRY_DSN }}
6262
VITE_SENTRY_RELEASE: web@${{ github.sha }}
6363

64-
# The SST stack owns opncd.ai until this push removes its Share Worker, so this job runs after the
64+
# The SST stack owned api.opencode.ai until this push removes its Api Worker, so this job runs after the
6565
# SST deploy to take the hostname without a custom-domain conflict.
66-
share:
66+
legacy:
6767
needs: deploy
6868
if: github.repository == 'anomalyco/opencode' && github.ref_name != 'beta'
6969
runs-on: blacksmith-4vcpu-ubuntu-2404
@@ -89,5 +89,20 @@ jobs:
8989
secret-ids: CLOUDFLARE_API_TOKEN,opencode/${{ github.ref_name }}/CLOUDFLARE_API_TOKEN
9090
parse-json-secrets: false
9191

92-
- run: bun run deploy:${{ github.ref_name }}
93-
working-directory: services/share
92+
# The GitHub App secrets are read here, not in the step above, so only this step ever has them. They reach cf
93+
# through a file in the runner's temp directory, never argv, and the file is removed when the step ends.
94+
- name: Deploy
95+
working-directory: services/legacy
96+
env:
97+
STAGE: ${{ github.ref_name }}
98+
# An explicit bash runs with pipefail, so a failed secret read fails the step.
99+
shell: bash
100+
run: |
101+
umask 077
102+
secrets="$RUNNER_TEMP/legacy-secrets.json"
103+
trap 'rm -f "$secrets"' EXIT
104+
for name in GITHUB_APP_ID GITHUB_APP_PRIVATE_KEY; do
105+
aws secretsmanager get-secret-value --secret-id "opencode/$STAGE/$name" --output json |
106+
jq --arg name "$name" '{($name): .SecretString}'
107+
done | jq -s add > "$secrets"
108+
bun run deploy:$STAGE --secrets-file "$secrets"

‎bun.lock‎

Lines changed: 73 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎infra/app.ts‎

Lines changed: 0 additions & 42 deletions
This file was deleted.

‎packages/function/package.json‎

Lines changed: 0 additions & 23 deletions
This file was deleted.

‎packages/function/sst-env.d.ts‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎packages/function/tsconfig.json‎

Lines changed: 0 additions & 10 deletions
This file was deleted.

‎script/release.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ import path from "path"
99
import { parseArgs } from "util"
1010

1111
const root = path.resolve(import.meta.dir, "..")
12-
// Commits that only touch these folders, such as the console, stats, cloud functions, docs, websites, and infra, are
12+
// Commits that only touch these folders, such as the console, stats, services, docs, websites, and infra, are
1313
// left out of the changelog.
1414
const changelogExclusions = [
1515
":(exclude)packages/console",
16-
":(exclude)packages/function",
1716
":(exclude)packages/stats",
1817
":(exclude)services",
1918
":(exclude)infra",

‎services/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ and clients live in `packages/`.
66
| Service | Purpose | Deployment |
77
| ---------------------- | ----------------------------------------- | ---------------------------- |
88
| [`site`](./site) | The opencode.ai website and V2 docs | `deploy-site.yml`, `cf` |
9-
| [`share`](./share) | Deprecated: sharing tombstone on opncd.ai | `deploy.yml`, `cf` |
9+
| [`legacy`](./legacy) | Deprecated: opncd.ai and api.opencode.ai | `deploy.yml`, `cf` |
1010
| [`updates`](./updates) | Release metadata and update selection | `release.yml`, Wrangler |
1111
| [`files`](./files) | Public file distribution at `/files/*` | `deploy-files.yml`, Wrangler |
1212

‎services/legacy/README.md‎

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Legacy (deprecated)
2+
3+
> **Deprecated.** What is left of V1's hosted services. Don't add features here. Each hostname can be
4+
> dropped whenever we're fine breaking the old clients that still call it.
5+
6+
One Worker that answers by hostname:
7+
8+
- `opncd.ai` (production) and `dev.opncd.ai` (development) are the retired session-sharing host.
9+
Session sharing was retired in #55716 and V2 has no sharing. They serve the "Session sharing has
10+
been discontinued" page, and the old `/api/share` endpoints still answer so V1 clients keep working
11+
(`src/share.ts`).
12+
- `api.opencode.ai` (production) and `api.dev.opencode.ai` (development) exchange a GitHub Actions
13+
OIDC token for a GitHub App installation token for the V1 GitHub Action
14+
(`POST /exchange_github_app_token`, `src/api.ts`).
15+
16+
`cloudflare.config.ts` defines the Worker. `deploy:dev` and `deploy:production` deploy it with `cf`,
17+
after the SST job in `.github/workflows/deploy.yml`, because the SST stack owned these hostnames until
18+
the Worker moved here. The deploy job reads the `GITHUB_APP_ID` and `GITHUB_APP_PRIVATE_KEY` Worker
19+
secrets from AWS Secrets Manager (`opencode/<stage>/GITHUB_APP_*`) and uploads them with
20+
`--secrets-file`.
21+
22+
| Environment | Worker | Hostnames |
23+
| ----------- | ---------------------------- | ------------------------------------- |
24+
| Development | `opencode-legacy-dev` | `dev.opncd.ai`, `api.dev.opencode.ai` |
25+
| Production | `opencode-legacy-production` | `opncd.ai`, `api.opencode.ai` |
26+
27+
```bash
28+
bun run typecheck
29+
bun test
30+
```

0 commit comments

Comments
 (0)