Skip to content

Commit

Permalink
fix auth (#86)
Browse files Browse the repository at this point in the history
  • Loading branch information
OliverMKing authored Jul 25, 2022
1 parent 484a640 commit 17cd774
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
41 changes: 41 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
8 changes: 7 additions & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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") {
Expand Down

0 comments on commit 17cd774

Please sign in to comment.