diff --git a/entry.js b/entry.js index e7543c7..2cdc580 100755 --- a/entry.js +++ b/entry.js @@ -40481,7 +40481,7 @@ function query({ // package.json var package_default = { name: "@pullfrog/action", - version: "0.0.92", + version: "0.0.93", type: "module", files: [ "index.js", @@ -40911,6 +40911,9 @@ function checkExistingToken() { const envToken = process.env.GITHUB_INSTALLATION_TOKEN; return inputToken || envToken || null; } +function getGitHubTokenInput() { + return core2.getInput("github_token") || null; +} function isGitHubActionsEnvironment() { return Boolean(process.env.GITHUB_ACTIONS); } @@ -41057,17 +41060,24 @@ async function acquireNewToken() { } } function getDefaultGitHubToken() { - if (isGitHubActionsEnvironment()) { + const inputToken = getGitHubTokenInput(); + if (inputToken) { + return inputToken; + } + const token = process.env.GITHUB_TOKEN; + if (!token && isGitHubActionsEnvironment()) { const githubEnvVars = Object.keys(process.env).filter((key) => key.startsWith("GITHUB_")).reduce( (acc, key) => { - acc[key] = key === "GITHUB_TOKEN" ? "***" : process.env[key]; + acc[key] = key === "GITHUB_TOKEN" ? process.env[key] ? "***SET***" : "NOT_SET" : process.env[key]; return acc; }, {} ); - log.debug(`GitHub env vars: ${JSON.stringify(githubEnvVars)}`); + log.warning( + `GITHUB_TOKEN not found. Available GITHUB_* env vars: ${JSON.stringify(githubEnvVars)}` + ); } - return process.env.GITHUB_TOKEN || null; + return token || null; } async function setupGitHubInstallationToken() { const existingToken = checkExistingToken(); diff --git a/package.json b/package.json index 73be1d1..b9bfb12 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@pullfrog/action", - "version": "0.0.92", + "version": "0.0.93", "type": "module", "files": [ "index.js", diff --git a/utils/github.ts b/utils/github.ts index 9256577..10f5baa 100644 --- a/utils/github.ts +++ b/utils/github.ts @@ -49,6 +49,10 @@ function checkExistingToken(): string | null { return inputToken || envToken || null; } +function getGitHubTokenInput(): string | null { + return core.getInput("github_token") || null; +} + function isGitHubActionsEnvironment(): boolean { return Boolean(process.env.GITHUB_ACTIONS); } @@ -255,21 +259,37 @@ async function acquireNewToken(): Promise { } function getDefaultGitHubToken(): string | null { - // Debug: log all GITHUB_* env vars - if (isGitHubActionsEnvironment()) { + // Try input first (explicitly passed from workflow) + const inputToken = getGitHubTokenInput(); + if (inputToken) { + return inputToken; + } + + // Then try environment variable (automatically set by GitHub Actions) + const token = process.env.GITHUB_TOKEN; + + // Log diagnostic info when GITHUB_TOKEN is missing + if (!token && isGitHubActionsEnvironment()) { const githubEnvVars = Object.keys(process.env) .filter((key) => key.startsWith("GITHUB_")) .reduce( (acc, key) => { - acc[key] = key === "GITHUB_TOKEN" ? "***" : process.env[key]; + acc[key] = + key === "GITHUB_TOKEN" + ? process.env[key] + ? "***SET***" + : "NOT_SET" + : process.env[key]; return acc; }, {} as Record ); - log.debug(`GitHub env vars: ${JSON.stringify(githubEnvVars)}`); + log.warning( + `GITHUB_TOKEN not found. Available GITHUB_* env vars: ${JSON.stringify(githubEnvVars)}` + ); } - return process.env.GITHUB_TOKEN || null; + return token || null; } /**