When `client-id` (or the deprecated `app-id`) resolves to an empty string, for example because a secret or variable is not available in the workflow context, the error message from `@octokit/auth-app` is not very helpful: ``` [@octokit/auth-app] appId option is required ``` A validation check was added recently to catch this earlier, but its message could be more informative: ``` Either 'client-id' or 'app-id' input must be set ``` This updates the message to clarify that the value resolved to empty and nudges users toward checking their secret or variable availability: ``` The 'client-id' input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context. ``` Closes #249 --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
56 lines
1.5 KiB
JavaScript
56 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 clientId = core.getInput("client-id") || core.getInput("app-id");
|
|
if (!clientId) {
|
|
throw new Error("The 'client-id' (or deprecated 'app-id') input must be set to a non-empty string. If using a secret or variable, ensure it is available in this workflow context.");
|
|
}
|
|
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);
|
|
});
|