Skip to content

Commit 8b298a2

Browse files
authored
github: add OIDC_BASE_URL for custom GitHub App installs (anomalyco#5756)
1 parent 6f43d03 commit 8b298a2

2 files changed

Lines changed: 14 additions & 2 deletions

File tree

github/action.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ inputs:
2626
description: "Comma-separated list of trigger phrases (case-insensitive). Defaults to '/opencode,/oc'"
2727
required: false
2828

29+
oidc_base_url:
30+
description: "Base URL for OIDC token exchange API. Only required when running a custom GitHub App install. Defaults to https://api.opencode.ai"
31+
required: false
32+
2933
runs:
3034
using: "composite"
3135
steps:
@@ -62,3 +66,4 @@ runs:
6266
PROMPT: ${{ inputs.prompt }}
6367
USE_GITHUB_TOKEN: ${{ inputs.use_github_token }}
6468
MENTIONS: ${{ inputs.mentions }}
69+
OIDC_BASE_URL: ${{ inputs.oidc_base_url }}

packages/opencode/src/cli/cmd/github.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ export const GithubRunCommand = cmd({
395395
const { providerID, modelID } = normalizeModel()
396396
const runId = normalizeRunId()
397397
const share = normalizeShare()
398+
const oidcBaseUrl = normalizeOidcBaseUrl()
398399
const { owner, repo } = context.repo
399400
const payload = context.payload as IssueCommentEvent | PullRequestReviewCommentEvent
400401
const issueEvent = isIssueCommentEvent(payload) ? payload : undefined
@@ -572,6 +573,12 @@ export const GithubRunCommand = cmd({
572573
throw new Error(`Invalid use_github_token value: ${value}. Must be a boolean.`)
573574
}
574575

576+
function normalizeOidcBaseUrl(): string {
577+
const value = process.env["OIDC_BASE_URL"]
578+
if (!value) return "https://api.opencode.ai"
579+
return value.replace(/\/+$/, "")
580+
}
581+
575582
function isIssueCommentEvent(
576583
event: IssueCommentEvent | PullRequestReviewCommentEvent,
577584
): event is IssueCommentEvent {
@@ -809,14 +816,14 @@ export const GithubRunCommand = cmd({
809816

810817
async function exchangeForAppToken(token: string) {
811818
const response = token.startsWith("github_pat_")
812-
? await fetch("https://api.opencode.ai/exchange_github_app_token_with_pat", {
819+
? await fetch(`${oidcBaseUrl}/exchange_github_app_token_with_pat`, {
813820
method: "POST",
814821
headers: {
815822
Authorization: `Bearer ${token}`,
816823
},
817824
body: JSON.stringify({ owner, repo }),
818825
})
819-
: await fetch("https://api.opencode.ai/exchange_github_app_token", {
826+
: await fetch(`${oidcBaseUrl}/exchange_github_app_token`, {
820827
method: "POST",
821828
headers: {
822829
Authorization: `Bearer ${token}`,

0 commit comments

Comments
 (0)