From f942b7797ff742375eb19d86c71c07b61c92b6f8 Mon Sep 17 00:00:00 2001 From: Parker Brown <17183625+parkerbxyz@users.noreply.github.com> Date: Fri, 20 Mar 2026 22:34:06 -0700 Subject: [PATCH] Rename enterprise input Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- README.md | 6 ++-- action.yml | 2 +- dist/main.cjs | 26 ++++++++-------- lib/main.js | 30 +++++++++---------- main.js | 4 +-- tests/index.js.snapshot | 4 +-- ...-enterprise-installation-not-found.test.js | 2 +- ...nterprise-mutual-exclusivity-owner.test.js | 6 ++-- ...se-mutual-exclusivity-repositories.test.js | 6 ++-- tests/main-enterprise-only-success.test.js | 4 +-- ...-enterprise-token-with-permissions.test.js | 2 +- 11 files changed, 46 insertions(+), 46 deletions(-) diff --git a/README.md b/README.md index b8f763c..0d887b4 100644 --- a/README.md +++ b/README.md @@ -209,7 +209,7 @@ jobs: with: app-id: ${{ vars.APP_ID }} private-key: ${{ secrets.PRIVATE_KEY }} - enterprise-slug: my-enterprise-slug + enterprise: my-enterprise-slug - name: Call enterprise management REST API with gh run: | gh api /enterprises/my-enterprise-slug/apps/installable_organizations @@ -375,12 +375,12 @@ steps: > [!NOTE] > If `owner` is set and `repositories` is empty, access will be scoped to all repositories in the provided repository owner's installation. If `owner` and `repositories` are empty, access will be scoped to only the current repository. -### `enterprise-slug` +### `enterprise` **Optional:** The slug of the enterprise to generate a token for enterprise-level app installations. > [!NOTE] -> The `enterprise-slug` input is mutually exclusive with `owner` and `repositories`. GitHub Apps can be installed on enterprise accounts with permissions that let them call enterprise management APIs. Enterprise installations do not grant access to organization or repository resources. +> The `enterprise` input is mutually exclusive with `owner` and `repositories`. GitHub Apps can be installed on enterprise accounts with permissions that let them call enterprise management APIs. Enterprise installations do not grant access to organization or repository resources. ### `permission-` diff --git a/action.yml b/action.yml index 0c1e044..50b69c6 100644 --- a/action.yml +++ b/action.yml @@ -17,7 +17,7 @@ inputs: repositories: description: "Comma or newline-separated list of repositories to install the GitHub App on (defaults to current repository if owner is unset)" required: false - enterprise-slug: + enterprise: description: "Enterprise slug for enterprise-level app installations (cannot be used with 'owner' or 'repositories')" required: false skip-token-revoke: diff --git a/dist/main.cjs b/dist/main.cjs index bc432f6..de54429 100644 --- a/dist/main.cjs +++ b/dist/main.cjs @@ -23153,13 +23153,13 @@ async function pRetry(input, options = {}) { } // lib/main.js -async function main(appId, privateKey, enterpriseSlug, owner, repositories, permissions, core, createAppAuth2, request2, skipTokenRevoke) { - if (enterpriseSlug && (owner || repositories.length > 0)) { - throw new Error("Cannot use 'enterprise-slug' input with 'owner' or 'repositories' inputs"); +async function main(appId, 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"); } let parsedOwner = ""; let parsedRepositoryNames = []; - if (!enterpriseSlug) { + if (!enterprise) { if (!owner && repositories.length === 0) { const [owner2, repo] = String(process.env.GITHUB_REPOSITORY).split("/"); parsedOwner = owner2; @@ -23192,7 +23192,7 @@ async function main(appId, privateKey, enterpriseSlug, owner, repositories, perm ); } } else { - core.info(`Creating enterprise installation token for enterprise "${enterpriseSlug}".`); + core.info(`Creating enterprise installation token for enterprise "${enterprise}".`); } const auth5 = createAppAuth2({ appId, @@ -23200,14 +23200,14 @@ async function main(appId, privateKey, enterpriseSlug, owner, repositories, perm request: request2 }); let authentication, installationId, appSlug; - if (enterpriseSlug) { + if (enterprise) { ({ authentication, installationId, appSlug } = await pRetry( - () => getTokenFromEnterprise(request2, auth5, enterpriseSlug, permissions), + () => getTokenFromEnterprise(request2, auth5, enterprise, permissions), { shouldRetry: ({ error: error2 }) => error2.status >= 500, onFailedAttempt: (context) => { core.info( - `Failed to create token for enterprise "${enterpriseSlug}" (attempt ${context.attemptNumber}): ${context.error.message}` + `Failed to create token for enterprise "${enterprise}" (attempt ${context.attemptNumber}): ${context.error.message}` ); }, retries: 3 @@ -23290,11 +23290,11 @@ async function getTokenFromRepository(request2, auth5, parsedOwner, parsedReposi const appSlug = response.data["app_slug"]; return { authentication, installationId, appSlug }; } -async function getTokenFromEnterprise(request2, auth5, enterpriseSlug, permissions) { +async function getTokenFromEnterprise(request2, auth5, enterprise, permissions) { let response; try { response = await request2("GET /enterprises/{enterprise}/installation", { - enterprise: enterpriseSlug, + enterprise, request: { hook: auth5.hook } @@ -23302,7 +23302,7 @@ async function getTokenFromEnterprise(request2, auth5, enterpriseSlug, permissio } catch (error2) { if (error2.status === 404) { throw new Error( - `No enterprise installation found matching the name ${enterpriseSlug}.` + `No enterprise installation found matching the name ${enterprise}.` ); } throw error2; @@ -23355,7 +23355,7 @@ async function run() { ensureNativeProxySupport(); const appId = getInput("app-id"); const privateKey = getInput("private-key"); - const enterpriseSlug = getInput("enterprise-slug"); + const enterprise = getInput("enterprise"); const owner = getInput("owner"); const repositories = getInput("repositories").split(/[\n,]+/).map((s) => s.trim()).filter((x) => x !== ""); const skipTokenRevoke = getBooleanInput("skip-token-revoke"); @@ -23363,7 +23363,7 @@ async function run() { return main( appId, privateKey, - enterpriseSlug, + enterprise, owner, repositories, permissions, diff --git a/lib/main.js b/lib/main.js index 9489cea..582adf9 100644 --- a/lib/main.js +++ b/lib/main.js @@ -4,7 +4,7 @@ import pRetry from "p-retry"; /** * @param {string} appId * @param {string} privateKey - * @param {string} enterpriseSlug + * @param {string} enterprise * @param {string} owner * @param {string[]} repositories * @param {undefined | Record} permissions @@ -16,7 +16,7 @@ import pRetry from "p-retry"; export async function main( appId, privateKey, - enterpriseSlug, + enterprise, owner, repositories, permissions, @@ -25,16 +25,16 @@ export async function main( request, skipTokenRevoke, ) { - // Validate mutual exclusivity of enterprise-slug with owner/repositories - if (enterpriseSlug && (owner || repositories.length > 0)) { - throw new Error("Cannot use 'enterprise-slug' input with 'owner' or 'repositories' inputs"); + // Validate mutual exclusivity of enterprise with owner/repositories + if (enterprise && (owner || repositories.length > 0)) { + throw new Error("Cannot use 'enterprise' input with 'owner' or 'repositories' inputs"); } let parsedOwner = ""; let parsedRepositoryNames = []; - // Skip owner/repository parsing if enterprise-slug is set - if (!enterpriseSlug) { + // Skip owner/repository parsing if enterprise is set + if (!enterprise) { // If neither owner nor repositories are set, default to current repository if (!owner && repositories.length === 0) { const [owner, repo] = String(process.env.GITHUB_REPOSITORY).split("/"); @@ -78,7 +78,7 @@ export async function main( ); } } else { - core.info(`Creating enterprise installation token for enterprise "${enterpriseSlug}".`); + core.info(`Creating enterprise installation token for enterprise "${enterprise}".`); } const auth = createAppAuth({ @@ -89,15 +89,15 @@ export async function main( let authentication, installationId, appSlug; - // If enterprise-slug is set, get installation ID from the enterprise - if (enterpriseSlug) { + // If enterprise is set, get installation ID from the enterprise + if (enterprise) { ({ authentication, installationId, appSlug } = await pRetry( - () => getTokenFromEnterprise(request, auth, enterpriseSlug, permissions), + () => getTokenFromEnterprise(request, auth, enterprise, permissions), { shouldRetry: ({ error }) => error.status >= 500, onFailedAttempt: (context) => { core.info( - `Failed to create token for enterprise "${enterpriseSlug}" (attempt ${context.attemptNumber}): ${context.error.message}` + `Failed to create token for enterprise "${enterprise}" (attempt ${context.attemptNumber}): ${context.error.message}` ); }, retries: 3, @@ -207,11 +207,11 @@ async function getTokenFromRepository( return { authentication, installationId, appSlug }; } -async function getTokenFromEnterprise(request, auth, enterpriseSlug, permissions) { +async function getTokenFromEnterprise(request, auth, enterprise, permissions) { let response; try { response = await request("GET /enterprises/{enterprise}/installation", { - enterprise: enterpriseSlug, + enterprise, request: { hook: auth.hook, }, @@ -220,7 +220,7 @@ async function getTokenFromEnterprise(request, auth, enterpriseSlug, permissions /* c8 ignore next 8 */ if (error.status === 404) { throw new Error( - `No enterprise installation found matching the name ${enterpriseSlug}.` + `No enterprise installation found matching the name ${enterprise}.` ); } diff --git a/main.js b/main.js index 63662f0..ec65c02 100644 --- a/main.js +++ b/main.js @@ -20,7 +20,7 @@ async function run() { const appId = core.getInput("app-id"); const privateKey = core.getInput("private-key"); - const enterpriseSlug = core.getInput("enterprise-slug"); + const enterprise = core.getInput("enterprise"); const owner = core.getInput("owner"); const repositories = core .getInput("repositories") @@ -35,7 +35,7 @@ async function run() { return main( appId, privateKey, - enterpriseSlug, + enterprise, owner, repositories, permissions, diff --git a/tests/index.js.snapshot b/tests/index.js.snapshot index e9700a2..ba868b6 100644 --- a/tests/index.js.snapshot +++ b/tests/index.js.snapshot @@ -35,7 +35,7 @@ GET /enterprises/test-enterprise/installation `; exports[`main-enterprise-mutual-exclusivity-owner.test.js > stderr 1`] = ` -Error: Cannot use 'enterprise-slug' input with 'owner' or 'repositories' inputs +Error: Cannot use 'enterprise' input with 'owner' or 'repositories' inputs at main (file:///lib/main.js::) at run (file:///main.js::) at file:///main.js:: @@ -45,7 +45,7 @@ Error: Cannot use 'enterprise-slug' input with 'owner' or 'repositories' inputs `; exports[`main-enterprise-mutual-exclusivity-repositories.test.js > stderr 1`] = ` -Error: Cannot use 'enterprise-slug' input with 'owner' or 'repositories' inputs +Error: Cannot use 'enterprise' input with 'owner' or 'repositories' inputs at main (file:///lib/main.js::) at run (file:///main.js::) at file:///main.js:: diff --git a/tests/main-enterprise-installation-not-found.test.js b/tests/main-enterprise-installation-not-found.test.js index 0c36a26..a578967 100644 --- a/tests/main-enterprise-installation-not-found.test.js +++ b/tests/main-enterprise-installation-not-found.test.js @@ -4,7 +4,7 @@ import { test } from "./main.js"; await test((mockPool) => { delete process.env.INPUT_OWNER; delete process.env.INPUT_REPOSITORIES; - process.env["INPUT_ENTERPRISE-SLUG"] = "test-enterprise"; + process.env.INPUT_ENTERPRISE = "test-enterprise"; // Mock the enterprise installation endpoint to return no matching installation mockPool diff --git a/tests/main-enterprise-mutual-exclusivity-owner.test.js b/tests/main-enterprise-mutual-exclusivity-owner.test.js index eaa36da..f247169 100644 --- a/tests/main-enterprise-mutual-exclusivity-owner.test.js +++ b/tests/main-enterprise-mutual-exclusivity-owner.test.js @@ -1,12 +1,12 @@ import { DEFAULT_ENV } from "./main.js"; -// Verify `main` exits with an error when `enterprise-slug` is used with `owner` input. +// Verify `main` exits with an error when `enterprise` is used with `owner` input. try { - // Set up environment with enterprise-slug and owner set + // Set up environment with enterprise and owner set for (const [key, value] of Object.entries(DEFAULT_ENV)) { process.env[key] = value; } - process.env["INPUT_ENTERPRISE-SLUG"] = "test-enterprise"; + process.env.INPUT_ENTERPRISE = "test-enterprise"; process.env.INPUT_OWNER = "test-owner"; await import("../main.js"); diff --git a/tests/main-enterprise-mutual-exclusivity-repositories.test.js b/tests/main-enterprise-mutual-exclusivity-repositories.test.js index c69f0f0..f6e92b9 100644 --- a/tests/main-enterprise-mutual-exclusivity-repositories.test.js +++ b/tests/main-enterprise-mutual-exclusivity-repositories.test.js @@ -1,12 +1,12 @@ import { DEFAULT_ENV } from "./main.js"; -// Verify `main` exits with an error when `enterprise-slug` is used with `repositories` input. +// Verify `main` exits with an error when `enterprise` is used with `repositories` input. try { - // Set up environment with enterprise-slug and repositories set + // Set up environment with enterprise and repositories set for (const [key, value] of Object.entries(DEFAULT_ENV)) { process.env[key] = value; } - process.env["INPUT_ENTERPRISE-SLUG"] = "test-enterprise"; + process.env.INPUT_ENTERPRISE = "test-enterprise"; process.env.INPUT_REPOSITORIES = "repo1,repo2"; await import("../main.js"); diff --git a/tests/main-enterprise-only-success.test.js b/tests/main-enterprise-only-success.test.js index 7f696ef..5008375 100644 --- a/tests/main-enterprise-only-success.test.js +++ b/tests/main-enterprise-only-success.test.js @@ -1,8 +1,8 @@ import { test } from "./main.js"; -// Verify `main` successfully obtains a token when only the `enterprise-slug` input is set. +// Verify `main` successfully obtains a token when only the `enterprise` input is set. await test((mockPool) => { - process.env["INPUT_ENTERPRISE-SLUG"] = "test-enterprise"; + process.env.INPUT_ENTERPRISE = "test-enterprise"; delete process.env.INPUT_OWNER; delete process.env.INPUT_REPOSITORIES; diff --git a/tests/main-enterprise-token-with-permissions.test.js b/tests/main-enterprise-token-with-permissions.test.js index 9f9c0cc..f1a7914 100644 --- a/tests/main-enterprise-token-with-permissions.test.js +++ b/tests/main-enterprise-token-with-permissions.test.js @@ -2,7 +2,7 @@ import { test } from "./main.js"; // Verify `main` successfully generates enterprise token with specific permissions. await test((mockPool) => { - process.env["INPUT_ENTERPRISE-SLUG"] = "test-enterprise"; + process.env.INPUT_ENTERPRISE = "test-enterprise"; delete process.env.INPUT_OWNER; delete process.env.INPUT_REPOSITORIES; process.env["INPUT_PERMISSION-ENTERPRISE-ORGANIZATIONS"] = "read";