|
|
@@ -395,6 +395,7 @@ export const GithubRunCommand = cmd({
|
|
|
const { providerID, modelID } = normalizeModel()
|
|
|
const runId = normalizeRunId()
|
|
|
const share = normalizeShare()
|
|
|
+ const oidcBaseUrl = normalizeOidcBaseUrl()
|
|
|
const { owner, repo } = context.repo
|
|
|
const payload = context.payload as IssueCommentEvent | PullRequestReviewCommentEvent
|
|
|
const issueEvent = isIssueCommentEvent(payload) ? payload : undefined
|
|
|
@@ -572,6 +573,12 @@ export const GithubRunCommand = cmd({
|
|
|
throw new Error(`Invalid use_github_token value: ${value}. Must be a boolean.`)
|
|
|
}
|
|
|
|
|
|
+ function normalizeOidcBaseUrl(): string {
|
|
|
+ const value = process.env["OIDC_BASE_URL"]
|
|
|
+ if (!value) return "https://api.opencode.ai"
|
|
|
+ return value.replace(/\/+$/, "")
|
|
|
+ }
|
|
|
+
|
|
|
function isIssueCommentEvent(
|
|
|
event: IssueCommentEvent | PullRequestReviewCommentEvent,
|
|
|
): event is IssueCommentEvent {
|
|
|
@@ -809,14 +816,14 @@ export const GithubRunCommand = cmd({
|
|
|
|
|
|
async function exchangeForAppToken(token: string) {
|
|
|
const response = token.startsWith("github_pat_")
|
|
|
- ? await fetch("https://api.opencode.ai/exchange_github_app_token_with_pat", {
|
|
|
+ ? await fetch(`${oidcBaseUrl}/exchange_github_app_token_with_pat`, {
|
|
|
method: "POST",
|
|
|
headers: {
|
|
|
Authorization: `Bearer ${token}`,
|
|
|
},
|
|
|
body: JSON.stringify({ owner, repo }),
|
|
|
})
|
|
|
- : await fetch("https://api.opencode.ai/exchange_github_app_token", {
|
|
|
+ : await fetch(`${oidcBaseUrl}/exchange_github_app_token`, {
|
|
|
method: "POST",
|
|
|
headers: {
|
|
|
Authorization: `Bearer ${token}`,
|