Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ed17e8ff6 | ||
|
|
4e7c8bb981 | ||
|
|
c6e917eb5e | ||
|
|
7446d29d60 | ||
|
|
22ac3ce88d | ||
|
|
8a18fa720b | ||
|
|
11bbbb9207 | ||
|
|
574fbc2143 | ||
|
|
b284f0ba18 |
16
.github/workflows/test.yaml
vendored
Normal file
16
.github/workflows/test.yaml
vendored
Normal 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
21
LICENSE
Normal 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.
|
||||
@@ -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
|
||||
|
||||
|
||||
17
action.yaml
17
action.yaml
@@ -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
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -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": {
|
||||
|
||||
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user