feat: initial commit

This commit is contained in:
Aarnav Tale
2022-04-07 09:53:26 -04:00
commit 1ab07bf721
3 changed files with 41 additions and 0 deletions

25
action.yaml Normal file
View File

@@ -0,0 +1,25 @@
name: Kubernetes CLI (kubectl)
description: GitHub Action to manage a K8s cluster using kubectl
author: Aarnav Tale <aarnav@tale.me>
branding:
icon: terminal
color: blue
inputs:
kubectl-version:
description: Version of the kubectl CLI to use
required: false
default: v1.23.0
base64-kube-config:
description: A base64 encoded reference to your authorization file (~/.kube/config)
required: true
runs:
using: composite
steps:
- name: Configure kubectl CLI
run: setup-kubectl.sh
shell: bash
- name: Authorize kubectl to the cluster
run: login-kubectl.sh
shell: bash
env:
BASE64_KUBE_CONFIG: ${{ inputs.base64-kube-config }}

7
login-kubectl.sh Normal file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
if [ ! -d "$HOME/.kube" ]; then
mkdir -p $HOME/.kube
fi
echo "$BASE64_KUBE_CONFIG" | base64 -d > $HOME/.kube/config

9
setup-kubectl.sh Normal file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
curl -LO "https://dl.k8s.io/release/${{ inputs.kubectl-version }}/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/${{ inputs.kubectl-version }}/bin/linux/amd64/kubectl.sha256"
echo "$(cat kubectl.sha256) kubectl" | sha256sum --check
mkdir $GITHUB_WORKSPACE/bin
mv kubectl $GITHUB_WORKSPACE/bin
echo "$GITHUB_WORKSPACE/bin" >> $GITHUB_PATH