From 5f1d64db9011ba65fb2a2d1032b4d7ae0e02d32e Mon Sep 17 00:00:00 2001 From: Noel Sabia Date: Sun, 18 Oct 2026 17:08:46 +0200 Subject: [PATCH] ci: bind opencode API key explicitly via opencode.json The headless CI container has no stored credentials, so auth depends entirely on the injected key. Generate an opencode.json at runtime that binds OPENCODE_API_KEY to the opencode-go provider explicitly, removing any dependence on env-var-to-provider mapping behavior. --- .gitea/workflows/pr-checker.yml | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/.gitea/workflows/pr-checker.yml b/.gitea/workflows/pr-checker.yml index 2f671c3..45f2515 100644 --- a/.gitea/workflows/pr-checker.yml +++ b/.gitea/workflows/pr-checker.yml @@ -210,9 +210,19 @@ jobs: # (variants: high, max). NOTE the provider prefix must be # "opencode-go", NOT "opencode" (Zen is a different, pay-per-call # provider and fails with 'Insufficient account funds'). - # Output is redirected (not piped through tee): if opencode fails, - # the job must fail here so the error log is never posted as a - # "review" comment. + # + # Belt and suspenders on auth: OPENCODE_API_KEY is exported for + # env-based pickup, AND an opencode.json is generated that binds + # the key to the opencode-go provider explicitly - so headless CI + # never depends on env-var mapping behavior. + printf '{ + "$schema": "https://opencode.ai/config.json", + "provider": { + "opencode-go": { + "options": { "apiKey": "%s" } + } + } + }' "$OPENCODE_API_KEY" > opencode.json # --print-logs: surface auth/provider errors in the CI log instead # of failing with an opaque exit code opencode run \