7b1d2aef87
Fixes #57 This PR implements the 3-step plan proposed by @gr2m in https://github.com/actions/create-github-app-token/issues/57#issuecomment-1751272252: > 1. Support both input types > 2. Log a deprecation warning for the old notation > 3. Add a test for deprecations Although this PR supports both input formats simultaneously, I opted _not_ to document the old format in the updated README. That’s a decision I’m happy to revisit, if y’all would prefer to have documentation for both the old and new formats.
50 lines
1.6 KiB
JavaScript
50 lines
1.6 KiB
JavaScript
// @ts-check
|
|
|
|
import core from "@actions/core";
|
|
import { createAppAuth } from "@octokit/auth-app";
|
|
|
|
import { main } from "./lib/main.js";
|
|
import request 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>'");
|
|
}
|
|
|
|
const appId = core.getInput("app-id") || core.getInput("app_id");
|
|
if (!appId) {
|
|
// The 'app_id' input was previously required, but it and 'app-id' are both optional now, until the former is removed. Still, we want to ensure that at least one of them is set.
|
|
throw new Error("Input required and not supplied: app-id");
|
|
}
|
|
const privateKey = core.getInput("private-key") || core.getInput("private_key");
|
|
if (!privateKey) {
|
|
// The 'private_key' input was previously required, but it and 'private-key' are both optional now, until the former is removed. Still, we want to ensure that at least one of them is set.
|
|
throw new Error("Input required and not supplied: private-key");
|
|
}
|
|
const owner = core.getInput("owner");
|
|
const repositories = core.getInput("repositories");
|
|
|
|
const skipTokenRevoke = Boolean(
|
|
core.getInput("skip-token-revoke") || core.getInput("skip_token_revoke")
|
|
);
|
|
|
|
main(
|
|
appId,
|
|
privateKey,
|
|
owner,
|
|
repositories,
|
|
core,
|
|
createAppAuth,
|
|
request.defaults({
|
|
baseUrl: process.env["GITHUB_API_URL"],
|
|
}),
|
|
skipTokenRevoke
|
|
).catch((error) => {
|
|
/* c8 ignore next 3 */
|
|
console.error(error);
|
|
core.setFailed(error.message);
|
|
});
|