diff --git a/README.md b/README.md index 9255b09..12e194f 100644 --- a/README.md +++ b/README.md @@ -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: '' # default is latest (stable) + token: ${{ secrets.GITHUB_TOKEN }} # only needed if version is 'latest' id: install ``` diff --git a/action.yml b/action.yml index f6ed113..78fa385 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/package-lock.json b/package-lock.json index 03e3356..13d0fed 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,6 +13,7 @@ "@actions/exec": "^1.0.0", "@actions/io": "^1.0.0", "@actions/tool-cache": "1.1.2", + "@octokit/auth-action": "^2.0.0", "@octokit/graphql": "^4.6.1", "semver": "^6.1.0" }, @@ -920,6 +921,29 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "node_modules/@octokit/auth-action": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-action/-/auth-action-2.0.0.tgz", + "integrity": "sha512-mH6i1qVLGAqIb0eh4CrX19MS90B638snykXwDeUiPn+WHc0ATddyJwD3nr/bsKaBtDPl48zrx1lg1ueLXKYybQ==", + "dependencies": { + "@octokit/auth-token": "^3.0.0", + "@octokit/types": "^6.0.3" + }, + "engines": { + "node": ">= 14" + } + }, + "node_modules/@octokit/auth-token": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-3.0.0.tgz", + "integrity": "sha512-MDNFUBcJIptB9At7HiV7VCvU3NcL4GnfCQaP8C5lrxWrRPMJBnemYtehaKSOlaM7AYxeRyj9etenu8LVpSpVaQ==", + "dependencies": { + "@octokit/types": "^6.0.3" + }, + "engines": { + "node": ">= 14" + } + }, "node_modules/@octokit/endpoint": { "version": "6.0.12", "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz", @@ -7057,6 +7081,23 @@ "@jridgewell/sourcemap-codec": "^1.4.10" } }, + "@octokit/auth-action": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-action/-/auth-action-2.0.0.tgz", + "integrity": "sha512-mH6i1qVLGAqIb0eh4CrX19MS90B638snykXwDeUiPn+WHc0ATddyJwD3nr/bsKaBtDPl48zrx1lg1ueLXKYybQ==", + "requires": { + "@octokit/auth-token": "^3.0.0", + "@octokit/types": "^6.0.3" + } + }, + "@octokit/auth-token": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@octokit/auth-token/-/auth-token-3.0.0.tgz", + "integrity": "sha512-MDNFUBcJIptB9At7HiV7VCvU3NcL4GnfCQaP8C5lrxWrRPMJBnemYtehaKSOlaM7AYxeRyj9etenu8LVpSpVaQ==", + "requires": { + "@octokit/types": "^6.0.3" + } + }, "@octokit/endpoint": { "version": "6.0.12", "resolved": "https://registry.npmjs.org/@octokit/endpoint/-/endpoint-6.0.12.tgz", diff --git a/package.json b/package.json index 1812993..9fa58a7 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "@actions/exec": "^1.0.0", "@actions/io": "^1.0.0", "@actions/tool-cache": "1.1.2", + "@octokit/auth-action": "^2.0.0", "@octokit/graphql": "^4.6.1", "semver": "^6.1.0" }, diff --git a/src/run.ts b/src/run.ts index bc8ead9..8461460 100644 --- a/src/run.ts +++ b/src/run.ts @@ -10,6 +10,8 @@ import * as fs from 'fs' import * as toolCache from '@actions/tool-cache' import * as core from '@actions/core' import {graphql} from '@octokit/graphql' +import {createActionAuth} from '@octokit/auth-action' +import {create} from 'domain' const helmToolName = 'helm' const stableHelmVersion = 'v3.9.0' @@ -49,7 +51,11 @@ export function getValidVersion(version: string): string { // Gets the latest helm version or returns a default stable if getting latest fails export async function getLatestHelmVersion(): Promise { try { - const {repository} = await graphql( + const auth = createActionAuth() + const graphqlAuthenticated = graphql.defaults({ + request: {hook: auth.hook} + }) + const {repository} = await graphqlAuthenticated( ` { repository(name: "helm", owner: "helm") {