Skip to content

Commit

Permalink
v3 new release (#87)
Browse files Browse the repository at this point in the history
add token
  • Loading branch information
github-actions[bot] committed Jul 25, 2022
1 parent e4f3964 commit 84b304d
Show file tree
Hide file tree
Showing 31 changed files with 1,057 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -10,6 +10,7 @@ Acceptable values are latest or any semantic version string like v3.5.0 Use this
- uses: azure/setup-helm@v3
with:
version: '<version>' # default is latest (stable)
token: ${{ secrets.GITHUB_TOKEN }} # only needed if version is 'latest'
id: install
```

Expand Down
3 changes: 3 additions & 0 deletions action.yml
Expand Up @@ -5,6 +5,9 @@ inputs:
description: 'Version of helm'
required: true
default: 'latest'
token:
description: GitHub token. Required only if 'version' == 'latest'
required: false
outputs:
helm-path:
description: 'Path to the cached helm binary'
Expand Down
105 changes: 104 additions & 1 deletion lib/index.js
Expand Up @@ -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:
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down
23 changes: 23 additions & 0 deletions node_modules/.package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions node_modules/@octokit/auth-action/LICENSE

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

179 changes: 179 additions & 0 deletions node_modules/@octokit/auth-action/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 84b304d

Please sign in to comment.