Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5aa0d1bacd | ||
|
|
93d421ead9 | ||
|
|
e49d06518c | ||
|
|
69c8dc994c | ||
|
|
e70828b58c | ||
|
|
d7c0fa7a71 |
16
package.json
16
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "kubectl-action",
|
||||
"version": "1.1.3",
|
||||
"version": "1.2.0",
|
||||
"scripts": {
|
||||
"dev": "ncc -smw --license licenses.txt build src/main.ts",
|
||||
"build": "ncc -sm --license licenses.txt build src/main.ts",
|
||||
@@ -9,14 +9,14 @@
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.10.0",
|
||||
"@actions/tool-cache": "^2.0.1",
|
||||
"undici": "^5.16.0"
|
||||
"undici": "^5.22.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^18.11.18",
|
||||
"@vercel/ncc": "^0.36.0",
|
||||
"eslint": "^8.32.0",
|
||||
"eslint-config-tale": "^1.0.15",
|
||||
"np": "^7.6.3",
|
||||
"typescript": "^4.9.4"
|
||||
"@types/node": "^20.3.2",
|
||||
"@vercel/ncc": "^0.36.1",
|
||||
"eslint": "^8.43.0",
|
||||
"eslint-config-tale": "^1.0.16",
|
||||
"np": "^8.0.4",
|
||||
"typescript": "^5.1.6"
|
||||
}
|
||||
}
|
||||
|
||||
2907
pnpm-lock.yaml
generated
2907
pnpm-lock.yaml
generated
File diff suppressed because it is too large
Load Diff
@@ -1,11 +1,11 @@
|
||||
import { platform } from 'node:process'
|
||||
import { env, platform } from 'node:process'
|
||||
|
||||
import { debug, getState, setFailed } from '@actions/core'
|
||||
import { setupKubeconfig } from 'login'
|
||||
import { installKubectl } from 'setup'
|
||||
import { teardown } from 'teardown'
|
||||
|
||||
if (platform === 'win32') {
|
||||
if (env.RUNNER_OS === 'Windows' || platform === 'win32') {
|
||||
setFailed('kubectl-action does not support Windows')
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ if (getState('kubectl-path')) {
|
||||
teardown()
|
||||
// eslint-disable-next-line unicorn/prefer-top-level-await
|
||||
.catch(error => {
|
||||
setFailed('Failed to install kubectl (this is a bug in kubectl-action): ')
|
||||
setFailed('Failed to teardown kubectl (this is a bug in kubectl-action): ')
|
||||
debug(JSON.stringify(error))
|
||||
})
|
||||
} else {
|
||||
|
||||
19
src/setup.ts
19
src/setup.ts
@@ -36,7 +36,7 @@ export async function installKubectl() {
|
||||
debug(`kubectl ${version} installed and cached at ${path}`)
|
||||
} catch {
|
||||
debug('Failed to download kubectl from dl.k8s.io')
|
||||
setFailed('Failed to download kubectl from dl.k8s.io')
|
||||
setFailed('Failed to download kubectl from dl.k8s.io\nPlease check the version you specified is valid')
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,11 +63,24 @@ async function fetchKubectl(version: string) {
|
||||
return join(cachedPath, 'kubectl')
|
||||
}
|
||||
|
||||
// TODO: Support other platforms
|
||||
const url = `https://dl.k8s.io/release/${version}/bin/linux/amd64/kubectl`
|
||||
const url = `https://dl.k8s.io/release/${version}/bin/${retrieveRunnerMetadata()}/kubectl`
|
||||
|
||||
console.log(`Downloading kubectl (${url})`)
|
||||
const downloadPath = await downloadTool(url)
|
||||
const toolPath = await cacheFile(downloadPath, 'kubectl', 'kubectl', version)
|
||||
return join(toolPath, 'kubectl')
|
||||
}
|
||||
|
||||
// Gets the proper architecture and OS for the current platform
|
||||
// This doesn't use node functions, but instead CI variables provided by GitHub
|
||||
function retrieveRunnerMetadata() {
|
||||
// Currently we don't support win32 platforms anyways
|
||||
const runnerSystem = env.RUNNER_OS === 'Linux' ? 'linux' : 'darwin'
|
||||
const runnerArch = env.RUNNER_ARCH?.toLowerCase()
|
||||
|
||||
if (runnerArch?.includes('arm')) {
|
||||
return `${runnerSystem}/arm64`
|
||||
}
|
||||
|
||||
return `${runnerSystem}/amd64`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user