ea0d3155e4
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
56 lines
1.4 KiB
JavaScript
56 lines
1.4 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 clientId = core.getInput("client-id") || core.getInput("app-id");
|
|
if (!clientId) {
|
|
throw new Error("Either 'client-id' or 'app-id' input must be set");
|
|
}
|
|
const privateKey = core.getInput("private-key");
|
|
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(
|
|
clientId,
|
|
privateKey,
|
|
owner,
|
|
repositories,
|
|
permissions,
|
|
core,
|
|
createAppAuth,
|
|
request,
|
|
skipTokenRevoke,
|
|
);
|
|
}
|
|
|
|
// Export promise for testing
|
|
export default run().catch((error) => {
|
|
/* c8 ignore next 3 */
|
|
console.error(error);
|
|
core.setFailed(error.message);
|
|
});
|