committed by
GitHub
parent
e4f3964f67
commit
84b304dfb7
105
lib/index.js
105
lib/index.js
@ -3449,6 +3449,104 @@ function _evaluateVersions(versions, versionSpec) {
|
||||
}
|
||||
//# sourceMappingURL=tool-cache.js.map
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 1586:
|
||||
/***/ ((__unused_webpack_module, exports, __nccwpck_require__) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
|
||||
var authToken = __nccwpck_require__(3948);
|
||||
|
||||
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 authToken.createTokenAuth(token);
|
||||
};
|
||||
|
||||
exports.createActionAuth = createActionAuth;
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 3948:
|
||||
/***/ ((__unused_webpack_module, exports) => {
|
||||
|
||||
"use strict";
|
||||
|
||||
|
||||
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
||||
|
||||
const REGEX_IS_INSTALLATION_LEGACY = /^v1\./;
|
||||
const REGEX_IS_INSTALLATION = /^ghs_/;
|
||||
const REGEX_IS_USER_TO_SERVER = /^ghu_/;
|
||||
async function auth(token) {
|
||||
const isApp = token.split(/\./).length === 3;
|
||||
const isInstallation = REGEX_IS_INSTALLATION_LEGACY.test(token) || REGEX_IS_INSTALLATION.test(token);
|
||||
const isUserToServer = REGEX_IS_USER_TO_SERVER.test(token);
|
||||
const tokenType = isApp ? "app" : isInstallation ? "installation" : isUserToServer ? "user-to-server" : "oauth";
|
||||
return {
|
||||
type: "token",
|
||||
token: token,
|
||||
tokenType
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Prefix token for usage in the Authorization header
|
||||
*
|
||||
* @param token OAuth token or JSON Web Token
|
||||
*/
|
||||
function withAuthorizationPrefix(token) {
|
||||
if (token.split(/\./).length === 3) {
|
||||
return `bearer ${token}`;
|
||||
}
|
||||
|
||||
return `token ${token}`;
|
||||
}
|
||||
|
||||
async function hook(token, request, route, parameters) {
|
||||
const endpoint = request.endpoint.merge(route, parameters);
|
||||
endpoint.headers.authorization = withAuthorizationPrefix(token);
|
||||
return request(endpoint);
|
||||
}
|
||||
|
||||
const createTokenAuth = function createTokenAuth(token) {
|
||||
if (!token) {
|
||||
throw new Error("[@octokit/auth-token] No token passed to createTokenAuth");
|
||||
}
|
||||
|
||||
if (typeof token !== "string") {
|
||||
throw new Error("[@octokit/auth-token] Token passed to createTokenAuth is not a string");
|
||||
}
|
||||
|
||||
token = token.replace(/^(token|bearer) +/i, "");
|
||||
return Object.assign(auth.bind(null, token), {
|
||||
hook: hook.bind(null, token)
|
||||
});
|
||||
};
|
||||
|
||||
exports.createTokenAuth = createTokenAuth;
|
||||
//# sourceMappingURL=index.js.map
|
||||
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 7509:
|
||||
@ -13103,6 +13201,7 @@ const fs = __nccwpck_require__(7147);
|
||||
const toolCache = __nccwpck_require__(3594);
|
||||
const core = __nccwpck_require__(6024);
|
||||
const graphql_1 = __nccwpck_require__(1660);
|
||||
const auth_action_1 = __nccwpck_require__(1586);
|
||||
const helmToolName = 'helm';
|
||||
const stableHelmVersion = 'v3.9.0';
|
||||
function run() {
|
||||
@ -13140,7 +13239,11 @@ exports.getValidVersion = getValidVersion;
|
||||
function getLatestHelmVersion() {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
try {
|
||||
const { repository } = yield graphql_1.graphql(`
|
||||
const auth = auth_action_1.createActionAuth();
|
||||
const graphqlAuthenticated = graphql_1.graphql.defaults({
|
||||
request: { hook: auth.hook }
|
||||
});
|
||||
const { repository } = yield graphqlAuthenticated(`
|
||||
{
|
||||
repository(name: "helm", owner: "helm") {
|
||||
releases(last: 100) {
|
||||
|
Reference in New Issue
Block a user