17 Commits
v1.1.3 ... main

Author SHA1 Message Date
Aarnav Tale
91f29e07f4 fix: aws example was incorrect 2024-06-05 22:46:34 -04:00
Aarnav Tale
efb34d6cb2 fix: use npm in ci 2024-03-19 20:51:30 -04:00
Aarnav Tale
767276df48 chore: v1.4.0 2024-03-19 20:49:56 -04:00
Aarnav Tale
2b874f780f chore: switch to npm 2024-03-19 20:47:55 -04:00
Aarnav Tale
716cfe229d feat: clobber the actual tag releases 2024-03-19 20:44:49 -04:00
Aarnav Tale
e93dd2d865 chore: turns out i cant indent 2024-02-06 01:38:40 -05:00
Aarnav Tale
9c4bb5002a chore: fix readme typo 2024-02-02 14:31:45 -05:00
Aarnav Tale
560e7ff9e2 chore: v1.3.0 2024-02-02 14:25:00 -05:00
Aarnav Tale
9685b6d613 chore: add aws example to readme 2024-02-02 14:16:41 -05:00
Aarnav Tale
c83ced7ece feat: update to node 20 and remove undici 2024-02-02 14:03:31 -05:00
Aarnav Tale
6e8a90cd56 fix: explicitly exit on windows runners 2024-02-02 14:03:09 -05:00
Aarnav Tale
5aa0d1bacd chore: v1.2.0 2023-06-28 22:16:04 -04:00
Aarnav Tale
93d421ead9 feat: use github actions env for windows check for extra resiliency 2023-06-28 22:15:24 -04:00
Aarnav Tale
e49d06518c feat: support arch and darwin/linux properly 2023-06-28 22:14:43 -04:00
Aarnav Tale
69c8dc994c chore: add better failure message for version resolving failures on kubectl 2023-06-28 22:09:13 -04:00
Aarnav Tale
e70828b58c fix: typo in teardown error message 2023-06-28 22:07:52 -04:00
Aarnav Tale
d7c0fa7a71 chore: update packages 2023-06-28 22:06:56 -04:00
9 changed files with 8630 additions and 3683 deletions

View File

@@ -15,9 +15,8 @@ jobs:
uses: actions/checkout@v3
- name: Build latest dist/ folder
run: |
npm install -g pnpm
pnpm install --frozen-lockfile
pnpm run build
npm ci
npm run build
- name: Upload dist/ folder
run: |
git config --global user.email "<41898282+github-actions[bot]@users.noreply.github.com>"
@@ -26,4 +25,5 @@ jobs:
git add -f dist README.md LICENSE action.yaml
git commit -m "chore: create ci release ($GITHUB_SHA)"
git tag --force v1
git tag --force $GITHUB_REF_NAME
git push -f --tags origin deploy

View File

@@ -13,9 +13,8 @@ jobs:
uses: actions/checkout@v3
- name: Build latest dist/ folder
run: |
npm install -g pnpm
pnpm install --frozen-lockfile
pnpm run build
npm ci
npm run build
- name: Upload dist/ folder
run: |
git config --global user.email "<41898282+github-actions[bot]@users.noreply.github.com>"

View File

@@ -12,7 +12,7 @@ To use this action, add the following step to your GitHub Action workflow:
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
```
Keep in mind that the action expects a base64 encoded string of your Kubernetes configuration. The simplest way to do that is to run `cat $HOME/.kube/config | base64` and save that output as an action secret.
Keep in mind that the action expects a base64 encoded string of your Kubernetes configuration. The simplest way to do that is to run `cat $HOME/.kube/config | base64` and save that output as an action secret. It's additionally possible to generate a config file using the `aws` CLI for EKS or any other tools with other cloud providers.
It's also possible to specify the version of the [kubectl](https://kubernetes.io/docs/reference/kubectl/) CLI to use. The current default release used by this action is the latest version.
@@ -40,3 +40,33 @@ jobs:
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
- run: kubectl get pods
```
Here's an example using AWS EKS:
```yaml
name: Kubectl Action
on:
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
aws-region: us-east-2
- name: Generate kubeconfig
run: |
{
echo 'EKS_CREDS<<EOF'
aws eks update-kubeconfig --region us-east-2 --name my-cluster --dry-run | base64
echo EOF
} >> $GITHUB_ENV
- uses: tale/kubectl-action@v1
with:
base64-kube-config: ${{ env.EKS_CREDS }}
- run: kubectl get pods
```

View File

@@ -13,6 +13,6 @@ inputs:
description: A base64 encoded reference to your authorization file (~/.kube/config)
required: true
runs:
using: node16
using: node20
main: dist/index.js
post: dist/index.js

8564
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -1,22 +1,21 @@
{
"name": "kubectl-action",
"version": "1.1.3",
"version": "1.4.0",
"scripts": {
"dev": "ncc -smw --license licenses.txt build src/main.ts",
"build": "ncc -sm --license licenses.txt build src/main.ts",
"push": "np --no-cleanup --no-publish --no-tests --message 'chore: v%s'"
},
"dependencies": {
"@actions/core": "^1.10.0",
"@actions/tool-cache": "^2.0.1",
"undici": "^5.16.0"
"@actions/core": "^1.10.1",
"@actions/tool-cache": "^2.0.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.11.30",
"@vercel/ncc": "^0.38.1",
"eslint": "^8.57.0",
"eslint-config-tale": "^1.0.16",
"np": "^9.2.0",
"typescript": "^5.4.2"
}
}

3658
pnpm-lock.yaml generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,13 @@
import { platform } from 'node:process'
import { env, exit, 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')
exit(1)
}
if (getState('kubectl-path')) {
@@ -14,7 +15,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 {

View File

@@ -4,7 +4,6 @@ import { env } from 'node:process'
import { addPath, debug, getInput, setFailed } from '@actions/core'
import { cacheFile, downloadTool, find } from '@actions/tool-cache'
import { fetch } from 'undici'
export async function installKubectl() {
debug('Running kubectl-action installKubectl()')
@@ -36,7 +35,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 +62,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`
}