77d42ce310
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
58 lines
1.5 KiB
JavaScript
58 lines
1.5 KiB
JavaScript
// @ts-check
|
|
|
|
import * as core from "@actions/core";
|
|
import { createAppAuth } from "@octokit/auth-app";
|
|
|
|
import { getPermissionsFromInputs } from "./lib/get-permissions-from-inputs.js";
|
|
import { main } from "./lib/main.js";
|
|
import request, { ensureNativeProxySupport } from "./lib/request.js";
|
|
|
|
if (!process.env.GITHUB_REPOSITORY) {
|
|
throw new Error("GITHUB_REPOSITORY missing, must be set to '<owner>/<repo>'");
|
|
}
|
|
|
|
if (!process.env.GITHUB_REPOSITORY_OWNER) {
|
|
throw new Error("GITHUB_REPOSITORY_OWNER missing, must be set to '<owner>'");
|
|
}
|
|
|
|
async function run() {
|
|
ensureNativeProxySupport();
|
|
|
|
const appId = core.getInput("app-id");
|
|
const privateKey = core.getInput("private-key");
|
|
const enterpriseSlug = core.getInput("enterprise-slug");
|
|
const owner = core.getInput("owner");
|
|
const repositories = core
|
|
.getInput("repositories")
|
|
.split(/[\n,]+/)
|
|
.map((s) => s.trim())
|
|
.filter((x) => x !== "");
|
|
|
|
const skipTokenRevoke = core.getBooleanInput("skip-token-revoke");
|
|
|
|
const permissions = getPermissionsFromInputs(process.env);
|
|
|
|
return main(
|
|
appId,
|
|
privateKey,
|
|
enterpriseSlug,
|
|
owner,
|
|
repositories,
|
|
permissions,
|
|
core,
|
|
createAppAuth,
|
|
request,
|
|
skipTokenRevoke,
|
|
);
|
|
}
|
|
|
|
// Export promise for testing
|
|
export default run().catch((error) => {
|
|
/* c8 ignore next 5 */
|
|
console.error(error);
|
|
// Don't set failed in test mode (when GITHUB_OUTPUT is undefined)
|
|
if (process.env.GITHUB_OUTPUT !== undefined) {
|
|
core.setFailed(error.message);
|
|
}
|
|
});
|