Files
setup-helm/node_modules/@octokit/auth-action/dist-src/index.js
github-actions[bot] 84b304dfb7 v3 new release (#87)
add token
2022-07-25 13:23:27 -04:00

20 lines
1.0 KiB
JavaScript

import { createTokenAuth } from "@octokit/auth-token";
export const createActionAuth = function createActionAuth() {
if (!process.env.GITHUB_ACTION) {
throw new Error("[@octokit/auth-action] `GITHUB_ACTION` environment variable is not set. @octokit/auth-action is meant to be used in GitHub Actions only.");
}
const definitions = [
process.env.GITHUB_TOKEN,
process.env.INPUT_GITHUB_TOKEN,
process.env.INPUT_TOKEN,
].filter(Boolean);
if (definitions.length === 0) {
throw new Error("[@octokit/auth-action] `GITHUB_TOKEN` variable is not set. It must be set on either `env:` or `with:`. See https://github.com/octokit/auth-action.js#createactionauth");
}
if (definitions.length > 1) {
throw new Error("[@octokit/auth-action] The token variable is specified more than once. Use either `with.token`, `with.GITHUB_TOKEN`, or `env.GITHUB_TOKEN`. See https://github.com/octokit/auth-action.js#createactionauth");
}
const token = definitions.pop();
return createTokenAuth(token);
};