1
0
mirror of https://github.com/Azure/setup-helm.git synced 2026-07-06 00:11:37 +00:00

Compare commits

..

2 Commits

Author SHA1 Message Date
Vidya Reddy 83902c34cd Clear and verify npm cache 2022-07-01 14:48:58 -07:00
Vidya Reddy 7b23fe67ac upgrade ncc version 2022-07-01 14:45:18 -07:00
9 changed files with 37 additions and 140 deletions
-28
View File
@@ -1,28 +0,0 @@
name: Bug Report
description: File a bug report, we will respond to this thread with any questions.
title: 'Bug: '
labels: ['bug', 'triage']
assignees: '@Azure/aks-atlanta'
body:
- type: input
id: What-happened
attributes:
label: What happened?
description: Tell us what happened and how is it different form the expected?
placeholder: Tell us what you see!
validations:
required: true
- type: input
id: Runner
attributes:
label: Runner
description: What runner are you using?
placeholder: Mention the runner info (self-hosted, operating system)
validations:
required: true
- type: input
id: Logs
attributes:
label: Relevant log output
description: Run in debug mode for the most verbose logs. Please feel free to attach a screenshot of the logs
render: shell
-6
View File
@@ -1,6 +0,0 @@
blank_issues_enabled: false
contact_links:
- name: GitHub Action "aks-set-context" Support
url: https://github.com/Azure/aks-set-context
security: https://github.com/Azure/aks-set-context/blob/main/SECURITY.md
about: Please ask and answer questions here.
@@ -1,13 +0,0 @@
name: Feature Request
description: File a Feature Request form, we will respond to this thread with any questions.
title: 'Feature Request: '
labels: ['Feature']
assignees: '@Azure/aks-atlanta'
body:
- type: input
id: Feature request
attributes:
label: Feature request
description: Provide example functionality and links to relevant docs
validations:
required: true
+3 -6
View File
@@ -4,22 +4,19 @@ Install a specific version of helm binary on the runner.
## Example
Acceptable values are latest or any semantic version string like v3.5.0 Use this action in workflow to define which version of helm will be used. v2 and v3 of this action only support Helm3.
Acceptable values are latest or any semantic version string like v3.5.0 Use this action in workflow to define which version of helm will be used. v2 and v3 of this action only supports Helm3.
```yaml
- uses: azure/setup-helm@v3
with:
version: '<version>' # default is latest (stable)
token: ${{ secrets.GITHUB_TOKEN }} # only needed if version is 'latest'
version: '<version>' # default is latest stable
id: install
```
> Note: When using latest version you might hit the GitHub GraphQL API hourly rate limit of 5,000. The action will then return the hardcoded default stable version (currently v3.9.0). If you rely on a certain version higher than the default, you should use that version instead of latest.
The cached helm binary path is prepended to the PATH environment variable as well as stored in the helm-path output variable.
Refer to the action metadata file for details about all the inputs https://github.com/Azure/setup-helm/blob/master/action.yml
## Contributing
# Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
-3
View File
@@ -5,9 +5,6 @@ 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
View File
@@ -13,7 +13,6 @@
"@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"
},
@@ -921,29 +920,6 @@
"@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",
@@ -7081,23 +7057,6 @@
"@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",
-1
View File
@@ -10,7 +10,6 @@
"@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"
},
+6 -2
View File
@@ -74,8 +74,12 @@ describe('run.ts', () => {
expect(os.type).toBeCalled()
})
test('getLatestHelmVersion() - return the stable version of HELM since its not authenticated', async () => {
expect(await run.getLatestHelmVersion()).toBe('v3.9.0')
test('getLatestHelmVersion() - return the latest version of HELM', async () => {
try {
expect(await run.getLatestHelmVersion()).toBe('v3.8.0')
} catch (e) {
return e
}
})
test('walkSync() - return path to the all files matching fileToFind in dir', () => {
+28 -40
View File
@@ -9,27 +9,23 @@ 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'
const stableHelmVersion = 'v3.8.0'
const helmAllReleasesUrl = 'https://api.github.com/repos/helm/helm/releases'
export async function run() {
let version = core.getInput('version', {required: true})
if (version !== 'latest' && version[0] !== 'v') {
core.info('Getting latest Helm version')
version = getValidVersion(version)
}
if (version.toLocaleLowerCase() === 'latest') {
version = await getLatestHelmVersion()
}
core.startGroup(`Downloading ${version}`)
const cachedPath = await downloadHelm(version)
core.endGroup()
core.debug(util.format('Downloading %s', version))
let cachedPath = await downloadHelm(version)
try {
if (!process.env['PATH'].startsWith(path.dirname(cachedPath))) {
@@ -39,50 +35,41 @@ export async function run() {
//do nothing, set as output variable
}
core.info(`Helm tool version '${version}' has been cached at ${cachedPath}`)
console.log(
`Helm tool version: '${version}' has been cached at ${cachedPath}`
)
core.setOutput('helm-path', cachedPath)
}
// Prefixes version with v
//Returns version with proper v before it
export function getValidVersion(version: string): string {
return 'v' + version
}
// Gets the latest helm version or returns a default stable if getting latest fails
// Downloads the helm releases JSON and parses all the recent versions of helm from it.
// Defaults to sending stable helm version if none are valid or if it fails
export async function getLatestHelmVersion(): Promise<string> {
const helmJSONPath: string = await toolCache.downloadTool(helmAllReleasesUrl)
try {
const auth = createActionAuth()
const graphqlAuthenticated = graphql.defaults({
request: {hook: auth.hook}
})
const {repository} = await graphqlAuthenticated(
`
{
repository(name: "helm", owner: "helm") {
releases(last: 100) {
nodes {
tagName
}
}
}
}
`
)
const releases: string[] = repository.releases.nodes
.reverse()
.map((node: {tagName: string}) => node.tagName)
const latestValidRelease = releases.find((tag) => isValidVersion(tag))
if (latestValidRelease) return latestValidRelease
const helmJSON = JSON.parse(fs.readFileSync(helmJSONPath, 'utf-8'))
for (let i in helmJSON) {
if (isValidVersion(helmJSON[i].tag_name)) {
return helmJSON[i].tag_name
}
}
} catch (err) {
core.warning(
`Error while fetching latest Helm release: ${err.toString()}. Using default version ${stableHelmVersion}`
util.format(
'Error while fetching the latest Helm release. Error: %s. Using default Helm version %s',
err.toString(),
stableHelmVersion
)
)
return stableHelmVersion
}
core.warning(
`Could not find valid release. Using default version ${stableHelmVersion}`
)
return stableHelmVersion
}
@@ -148,9 +135,10 @@ export async function downloadHelm(version: string): Promise<string> {
)
} catch (exception) {
throw new Error(
`Failed to download Helm from location ${getHelmDownloadURL(
version
)}`
util.format(
'Failed to download Helm from location',
getHelmDownloadURL(version)
)
)
}