Skip to content

Commit acb6d66

Browse files
Fix GHA to work with a CodeBoarding license
1 parent ca687f7 commit acb6d66

1 file changed

Lines changed: 34 additions & 22 deletions

File tree

action.yml

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ inputs:
2020
required: false
2121
default: 'https://auduihjmm4b735zci7vyabuikq0hppqn.lambda-url.us-east-1.on.aws' # prod gha_proxy Function URL (licensing-aws LicensingStack-Stateless-prod)
2222
license_key:
23-
description: 'A CodeBoarding license key (e.g. secrets.CODEBOARDING_LICENSE) for unmetered hosted usage via proxy_url. Takes precedence over the free OIDC tier; ignored when llm_api_key is set (BYO key talks to the provider directly).'
23+
description: 'A CodeBoarding license key (e.g. secrets.CODEBOARDING_LICENSE) for unmetered hosted usage via proxy_url. Requires "permissions: id-token: write" — the license rides the OIDC bearer (the proxy still verifies the OIDC identity, then the license skips the quota). Takes precedence over the free OIDC tier; ignored when llm_api_key is set (BYO key talks to the provider directly).'
2424
required: false
2525
default: ''
2626
github_token:
@@ -547,9 +547,10 @@ runs:
547547
548548
# ── Hosted modes (license / oidc): provider is always OpenRouter via proxy ──
549549
# The hosted tiers run on CodeBoarding's OpenRouter account, so the engine
550-
# always talks OpenRouter here (the bearer is the license/OIDC token, which
551-
# the proxy swaps for the real key). To use a DIFFERENT provider, set
552-
# llm_api_key for that provider (that's BYO-key mode, below).
550+
# always talks OpenRouter here. The bearer is the OIDC JWT (free) or the OIDC
551+
# JWT packed with the license (license mode); the proxy verifies the OIDC,
552+
# applies the license, and swaps in the real OpenRouter key. To use a DIFFERENT
553+
# provider, set llm_api_key for that provider (that's BYO-key mode, below).
553554
if [ "$MODE" != "byokey" ]; then
554555
if [ -z "$PROXY_URL" ]; then
555556
echo "::error::proxy_url is empty but no llm_api_key was provided. Set llm_api_key, or restore proxy_url."
@@ -565,26 +566,37 @@ runs:
565566
AGENT_MODEL="${AGENT_MODEL:-google/gemini-3-flash-preview}"
566567
PARSING_MODEL="${PARSING_MODEL:-google/gemini-3.1-flash-lite-preview}"
567568
569+
# Both hosted tiers (free + license) authenticate to the proxy with a
570+
# GitHub OIDC JWT — it's the unforgeable per-repo identity the proxy meters
571+
# and abuse-checks on, so it is mandatory even when a license is present.
572+
# The engine (ChatOpenAI) can only set the bearer, not a custom header, so a
573+
# license rides the bearer alongside the OIDC token as `<jwt>~cblic~<license>`;
574+
# the proxy splits on that separator (KEEP IN SYNC with gha_proxy handler).
575+
# ACTIONS_ID_TOKEN_REQUEST_URL/_TOKEN are injected into the runner process env
576+
# (NOT the `env` context) only when the job grants `id-token: write`; read them
577+
# directly from the shell env.
578+
if [ -z "${ACTIONS_ID_TOKEN_REQUEST_URL:-}" ] || [ -z "${ACTIONS_ID_TOKEN_REQUEST_TOKEN:-}" ]; then
579+
echo "::error::No GitHub OIDC token available. Add \`permissions: id-token: write\` to the job (the hosted tier — free and license — needs the OIDC token to identify your repository; an llm_api_key avoids the proxy entirely)."
580+
exit 1
581+
fi
582+
OIDC_RESP="$(curl -sS --max-time 15 \
583+
-H "Authorization: Bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
584+
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=codeboarding-proxy" || true)"
585+
OIDC_JWT="$(printf '%s' "$OIDC_RESP" | python3 -c 'import json,sys;print(json.load(sys.stdin).get("value",""))' 2>/dev/null || true)"
586+
if [ -z "$OIDC_JWT" ]; then
587+
echo "::error::Failed to mint a GitHub OIDC token (is \`permissions: id-token: write\` granted?)."
588+
exit 1
589+
fi
590+
echo "::add-mask::$OIDC_JWT"
591+
568592
if [ "$MODE" = "license" ]; then
569-
BEARER="$LICENSE"
570-
echo "Using CodeBoarding license via hosted proxy."
593+
# Pack the license after the OIDC JWT; the proxy verifies the JWT (identity)
594+
# and validates the license (skips the free quota). Mask both halves.
595+
echo "::add-mask::$LICENSE"
596+
BEARER="${OIDC_JWT}~cblic~${LICENSE}"
597+
echo "Using CodeBoarding license via hosted proxy (OIDC-identified)."
571598
else
572-
# Mint a GitHub Actions OIDC JWT (audience must match the proxy's).
573-
# ACTIONS_ID_TOKEN_REQUEST_URL/_TOKEN are injected into the runner
574-
# process env (NOT the `env` context) only when the job grants
575-
# `id-token: write`; read them directly from the shell env.
576-
if [ -z "${ACTIONS_ID_TOKEN_REQUEST_URL:-}" ] || [ -z "${ACTIONS_ID_TOKEN_REQUEST_TOKEN:-}" ]; then
577-
echo "::error::No GitHub OIDC token available. Add \`permissions: id-token: write\` to the job (or set an llm_api_key / license_key). The free hosted tier needs the OIDC token to identify your repository."
578-
exit 1
579-
fi
580-
OIDC_RESP="$(curl -sS --max-time 15 \
581-
-H "Authorization: Bearer ${ACTIONS_ID_TOKEN_REQUEST_TOKEN}" \
582-
"${ACTIONS_ID_TOKEN_REQUEST_URL}&audience=codeboarding-proxy" || true)"
583-
BEARER="$(printf '%s' "$OIDC_RESP" | python3 -c 'import json,sys;print(json.load(sys.stdin).get("value",""))' 2>/dev/null || true)"
584-
if [ -z "$BEARER" ]; then
585-
echo "::error::Failed to mint a GitHub OIDC token (is \`permissions: id-token: write\` granted?)."
586-
exit 1
587-
fi
599+
BEARER="$OIDC_JWT"
588600
echo "Using the free hosted tier via a GitHub OIDC token (metered per repository owner)."
589601
fi
590602

0 commit comments

Comments
 (0)