9 Commits

Author SHA1 Message Date
Aarnav Tale
3ed17e8ff6 chore: v1.0.8 2023-01-25 01:00:21 -05:00
Aarnav Tale
4e7c8bb981 fix: use correct post file 2023-01-25 01:00:12 -05:00
Aarnav Tale
c6e917eb5e fix: parse the latest flag properly 2023-01-25 01:00:04 -05:00
Aarnav Tale
7446d29d60 feat: implement github actions for testing 2023-01-25 00:58:09 -05:00
Aarnav Tale
22ac3ce88d chore: add license and update readme 2023-01-25 00:51:07 -05:00
Aarnav Tale
8a18fa720b fix: actually push tags 2023-01-25 00:45:20 -05:00
Aarnav Tale
11bbbb9207 chore: v1.0.7 2023-01-25 00:45:01 -05:00
Aarnav Tale
574fbc2143 fix: make action run using node16 2023-01-25 00:44:53 -05:00
Aarnav Tale
b284f0ba18 fix: add tagging on the push command 2023-01-25 00:43:59 -05:00
8 changed files with 52 additions and 22 deletions

16
.github/workflows/test.yaml vendored Normal file
View File

@@ -0,0 +1,16 @@
name: Kubectl Action
on:
push:
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Setup tale/kubectl-action
uses: tale/kubectl-action@v1
with:
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
- name: Test the output of `kubectl cluster-info`
run: kubectl cluster-info

21
LICENSE Normal file
View File

@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2023 Aarnav Tale
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@@ -1,8 +1,11 @@
# kubectl-action
GitHub Action to manage a K8s (Kubernetes) cluster using kubectl.
# Usage
## Usage
To use this action, add the following step to your GitHub Action workflow:
```yaml
- uses: tale/kubectl-action@v1
with:
@@ -11,7 +14,8 @@ To use this action, add the following step to your GitHub Action workflow:
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 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 `v1.26.0`.
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.
```yaml
- uses: tale/kubectl-action@v1
with:
@@ -20,6 +24,7 @@ It's also possible to specify the version of the [kubectl](https://kubernetes.io
```
Once you've completed this setup, you have direct access to the `kubectl` binary and command in the rest of your actions. Here's a full example to give you some inspiration:
```yaml
name: Kubectl Action

View File

@@ -13,17 +13,6 @@ inputs:
description: A base64 encoded reference to your authorization file (~/.kube/config)
required: true
runs:
using: composite
steps:
- run: echo "${{ github.action_path }}" >> $GITHUB_PATH
shell: bash
- name: Configure kubectl CLI
run: setup-kubectl.sh
shell: bash
env:
KUBECTL_VERSION: ${{ inputs.kubectl-version }}
- name: Authorize kubectl to the cluster
run: login-kubectl.sh
shell: bash
env:
BASE64_KUBE_CONFIG: ${{ inputs.base64-kube-config }}
using: node16
main: dist/index.js
post: dist/index.js

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@@ -1,11 +1,10 @@
{
"name": "kubectl-action",
"version": "1.0.6",
"version": "1.0.8",
"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'",
"postpush": "git tag --force v1 && git push -f",
"push": "np --no-cleanup --no-publish --no-tests --message 'chore: v%s' && git tag --force v1 && git push -f --tags",
"version": "pnpm run build && git add dist"
},
"dependencies": {

View File

@@ -21,7 +21,7 @@ export async function installKubectl() {
trimWhitespace: true
})
const version = input || await fetchLatestVersion()
const version = input === 'latest' ? await fetchLatestVersion() : input
if (!version?.startsWith('v')) {
setFailed('Unable to determine the `kubectl` version to install')