Rename enterprise input

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Parker Brown
2026-03-20 22:34:06 -07:00
parent 17e8e94b15
commit f942b7797f
11 changed files with 46 additions and 46 deletions
+3 -3
View File
@@ -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-<permission name>`
+1 -1
View File
@@ -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:
+13 -13
View File
@@ -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,
+15 -15
View File
@@ -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<string, string>} 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}.`
);
}
+2 -2
View File
@@ -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,
+2 -2
View File
@@ -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://<cwd>/lib/main.js:<line>:<column>)
at run (file://<cwd>/main.js:<line>:<column>)
at file://<cwd>/main.js:<line>:<column>
@@ -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://<cwd>/lib/main.js:<line>:<column>)
at run (file://<cwd>/main.js:<line>:<column>)
at file://<cwd>/main.js:<line>:<column>
@@ -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
@@ -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");
@@ -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");
+2 -2
View File
@@ -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;
@@ -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";