fix auth (#86)

This commit is contained in:
Oliver King
2022-07-25 13:13:50 -04:00
committed by GitHub
parent 484a64052d
commit 17cd77473c
5 changed files with 53 additions and 1 deletions

View File

@ -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
```

View File

@ -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'

41
package-lock.json generated
View File

@ -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",

View File

@ -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"
},

View File

@ -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<string> {
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") {