diff --git a/dispatch/entry b/dispatch/entry index 7fb3e62..b7ea9f4 100755 --- a/dispatch/entry +++ b/dispatch/entry @@ -104337,6 +104337,7 @@ async function acquireNewToken(opts) { var githubInstallationToken; async function setupGitHubInstallationToken() { assert2(!githubInstallationToken, "GitHub installation token is already set."); + process.env.ORIGINAL_GITHUB_TOKEN = process.env.GITHUB_TOKEN; const acquiredToken = await acquireNewToken(); core2.setSecret(acquiredToken); githubInstallationToken = acquiredToken; @@ -104389,10 +104390,10 @@ function createOctokit(token) { return new OctokitWithPlugins({ auth: token, throttle: { - onRateLimit: (retryAfter, options, octokit, retryCount) => { + onRateLimit: (_retryAfter, _options, _octokit, retryCount) => { return retryCount <= 2; }, - onSecondaryRateLimit: (retryAfter, options, octokit, retryCount) => { + onSecondaryRateLimit: (_retryAfter, _options, _octokit, retryCount) => { return retryCount <= 2; } } @@ -138026,6 +138027,9 @@ function filterEnv(isPublicRepo) { if (isPublicRepo && isSensitive(key)) continue; filtered[key] = value2; } + if (process.env.ORIGINAL_GITHUB_TOKEN) { + filtered.GITHUB_TOKEN = process.env.ORIGINAL_GITHUB_TOKEN; + } return filtered; } function spawnSandboxed(command, options) { diff --git a/entry b/entry index 99a7b0b..3cb6b3d 100755 --- a/entry +++ b/entry @@ -104337,6 +104337,7 @@ async function acquireNewToken(opts) { var githubInstallationToken; async function setupGitHubInstallationToken() { assert2(!githubInstallationToken, "GitHub installation token is already set."); + process.env.ORIGINAL_GITHUB_TOKEN = process.env.GITHUB_TOKEN; const acquiredToken = await acquireNewToken(); core2.setSecret(acquiredToken); githubInstallationToken = acquiredToken; @@ -104389,10 +104390,10 @@ function createOctokit(token) { return new OctokitWithPlugins({ auth: token, throttle: { - onRateLimit: (retryAfter, options, octokit, retryCount) => { + onRateLimit: (_retryAfter, _options, _octokit, retryCount) => { return retryCount <= 2; }, - onSecondaryRateLimit: (retryAfter, options, octokit, retryCount) => { + onSecondaryRateLimit: (_retryAfter, _options, _octokit, retryCount) => { return retryCount <= 2; } } @@ -138026,6 +138027,9 @@ function filterEnv(isPublicRepo) { if (isPublicRepo && isSensitive(key)) continue; filtered[key] = value2; } + if (process.env.ORIGINAL_GITHUB_TOKEN) { + filtered.GITHUB_TOKEN = process.env.ORIGINAL_GITHUB_TOKEN; + } return filtered; } function spawnSandboxed(command, options) { diff --git a/mcp/bash.ts b/mcp/bash.ts index 9773e87..82af8f7 100644 --- a/mcp/bash.ts +++ b/mcp/bash.ts @@ -26,6 +26,11 @@ function filterEnv(isPublicRepo: boolean): Record { if (isPublicRepo && isSensitive(key)) continue; filtered[key] = value; } + // restore original GITHUB_TOKEN (the one set by GitHub Actions, not our installation token) + // this allows git operations in subprocesses to work while keeping our installation token secure + if (process.env.ORIGINAL_GITHUB_TOKEN) { + filtered.GITHUB_TOKEN = process.env.ORIGINAL_GITHUB_TOKEN; + } return filtered; } diff --git a/run/entry b/run/entry index c904e84..9ba258b 100755 --- a/run/entry +++ b/run/entry @@ -104337,6 +104337,7 @@ async function acquireNewToken(opts) { var githubInstallationToken; async function setupGitHubInstallationToken() { assert2(!githubInstallationToken, "GitHub installation token is already set."); + process.env.ORIGINAL_GITHUB_TOKEN = process.env.GITHUB_TOKEN; const acquiredToken = await acquireNewToken(); core2.setSecret(acquiredToken); githubInstallationToken = acquiredToken; @@ -104389,10 +104390,10 @@ function createOctokit(token) { return new OctokitWithPlugins({ auth: token, throttle: { - onRateLimit: (retryAfter, options, octokit, retryCount) => { + onRateLimit: (_retryAfter, _options, _octokit, retryCount) => { return retryCount <= 2; }, - onSecondaryRateLimit: (retryAfter, options, octokit, retryCount) => { + onSecondaryRateLimit: (_retryAfter, _options, _octokit, retryCount) => { return retryCount <= 2; } } @@ -138026,6 +138027,9 @@ function filterEnv(isPublicRepo) { if (isPublicRepo && isSensitive(key)) continue; filtered[key] = value2; } + if (process.env.ORIGINAL_GITHUB_TOKEN) { + filtered.GITHUB_TOKEN = process.env.ORIGINAL_GITHUB_TOKEN; + } return filtered; } function spawnSandboxed(command, options) { diff --git a/utils/github.ts b/utils/github.ts index 9dad0cd..8bf5803 100644 --- a/utils/github.ts +++ b/utils/github.ts @@ -230,6 +230,7 @@ const findInstallationId = async ( ); }; +// for local development only async function acquireTokenViaGitHubApp(): Promise { const repoContext = parseRepoContext(); @@ -263,6 +264,8 @@ let githubInstallationToken: string | undefined; */ export async function setupGitHubInstallationToken() { assert(!githubInstallationToken, "GitHub installation token is already set."); + // store original GITHUB_TOKEN before we overwrite it (used by filterEnv in bash.ts) + process.env.ORIGINAL_GITHUB_TOKEN = process.env.GITHUB_TOKEN; const acquiredToken = await acquireNewToken(); core.setSecret(acquiredToken); githubInstallationToken = acquiredToken; @@ -339,10 +342,10 @@ export function createOctokit(token: string): OctokitWithPlugins { return new OctokitWithPlugins({ auth: token, throttle: { - onRateLimit: (retryAfter, options, octokit, retryCount) => { + onRateLimit: (_retryAfter, _options, _octokit, retryCount) => { return retryCount <= 2; }, - onSecondaryRateLimit: (retryAfter, options, octokit, retryCount) => { + onSecondaryRateLimit: (_retryAfter, _options, _octokit, retryCount) => { return retryCount <= 2; }, },