diff --git a/.release-please-manifest.json b/.release-please-manifest.json index 6110c0f..cb15977 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "3.3.0" + ".": "3.4.0-beta" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 507d40e..430272f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [3.4.0-beta](https://github.com/actions/create-github-app-token/compare/v3.3.0...v3.4.0-beta) (2026-11-17) + + +### Features + +* support GitHub Actions OIDC authentication ([#411](https://github.com/actions/create-github-app-token/issues/411)) ([8240f10](https://github.com/actions/create-github-app-token/commit/8240f10d3ae05b4d450da83e8e247111a36eaf2c)) + ## [3.3.0](https://github.com/actions/create-github-app-token/compare/v3.2.0...v3.3.0) (2026-10-12) diff --git a/dist/main.cjs b/dist/main.cjs index 6158842..d645fbf 100644 --- a/dist/main.cjs +++ b/dist/main.cjs @@ -23991,17 +23991,47 @@ async function pRetry(input, options = {}) { throw new Error("Retry attempts exhausted without throwing an error."); } +// lib/create-oidc-auth.js +async function createOidcAuth(clientId, core, request2) { + const audience = `${process.env.GITHUB_SERVER_URL || "https://github.com"}/login/oauth`; + const token = await core.getIDToken(audience); + const auth5 = async ({ installationId, repositoryNames, permissions }) => { + const { data } = await request2( + "POST /app/installations/{installation_id}/access_tokens{?client_id}", + { + installation_id: installationId, + client_id: clientId, + repositories: repositoryNames, + permissions, + headers: { authorization: `Bearer ${token}` } + } + ); + return { token: data.token, expiresAt: data.expires_at }; + }; + auth5.hook = (hookRequest, route, parameters) => { + const endpoint2 = hookRequest.endpoint(route, parameters); + const url = new URL(endpoint2.url); + url.searchParams.set("client_id", clientId); + endpoint2.url = url.toString(); + endpoint2.headers.authorization = `Bearer ${token}`; + return hookRequest(endpoint2); + }; + return auth5; +} + // lib/main.js async function main(clientId, privateKey, enterprise, owner, repositories, permissions, core, createAppAuth2, request2, skipTokenRevoke) { if (enterprise && (owner || repositories.length > 0)) { throw new Error("Cannot use 'enterprise' input with 'owner' or 'repositories' inputs"); } + if (enterprise && !privateKey) { + throw new Error("The 'enterprise' input requires 'private-key'; OIDC authentication is not supported for enterprise installations."); + } const target = resolveInstallationTarget(enterprise, owner, repositories, core); - const auth5 = createAppAuth2({ - appId: clientId, - privateKey, - request: request2 - }); + if (!privateKey) { + core.info("No 'private-key' provided; authenticating with GitHub Actions OIDC."); + } + const auth5 = privateKey ? createAppAuth2({ appId: clientId, privateKey, request: request2 }) : await createOidcAuth(clientId, core, request2); const { authentication, installationId, appSlug } = await pRetry( () => getTokenFromTarget(request2, auth5, target, permissions), createTokenRetryOptions(core, getTokenRetryDescription(target)) @@ -24222,7 +24252,12 @@ async function run() { } const privateKey = getInput("private-key"); if (!privateKey) { - throw new Error("The 'private-key' input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context."); + if (!process.env.ACTIONS_ID_TOKEN_REQUEST_URL || !process.env.ACTIONS_ID_TOKEN_REQUEST_TOKEN) { + throw new Error("The 'private-key' input must be set to a non-empty string, or the workflow must have 'id-token: write' permissions to authenticate with OIDC. If using a secret or variable, ensure it is available in this workflow context."); + } + if (!getInput("client-id")) { + throw new Error("The 'client-id' input is required for OIDC authentication. The deprecated 'app-id' input is only supported with 'private-key'."); + } } const enterprise = getInput("enterprise"); const owner = getInput("owner"); diff --git a/package-lock.json b/package-lock.json index bb3e6d7..f8111c0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "create-github-app-token", - "version": "3.3.0", + "version": "3.4.0-beta", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "create-github-app-token", - "version": "3.3.0", + "version": "3.4.0-beta", "license": "MIT", "dependencies": { "@actions/core": "^3.0.1", diff --git a/package.json b/package.json index 57c0304..332f189 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "create-github-app-token", "private": true, "type": "module", - "version": "3.3.0", + "version": "3.4.0-beta", "description": "GitHub Action for creating a GitHub App Installation Access Token", "engines": { "node": ">=24.4.0"