1
0
Fork 0
mirror of https://github.com/imjasonh/gke-auth synced 2026-07-07 00:23:18 +00:00
gke-auth/action.yaml
minhthong582000 8f2b6af6f1 Add --alias flag to customize kubeconfig context name
By default the context/cluster/user entries in kubeconfig are named
gke_{project}_{location}_{cluster}, which is verbose and hard to type.
Add --alias so users can set a short, memorable name instead.
2026-06-05 02:04:21 +07:00

69 lines
2.1 KiB
YAML

name: 'Setup GKE Auth'
description: 'Authorize to a GKE cluster'
branding:
icon: cloud-lightning
color: blue
inputs:
version:
description: 'Version of gke-auth to install (tip, latest-release, v0.1, etc.)'
required: true
default: 'latest-release'
project:
description: "GCP project"
required: true
location:
description: "Region or zone of the cluster"
required: true
cluster:
description: "Name of the cluster"
required: true
alias:
description: "Alias name for the kubeconfig context (defaults to gke_{project}_{location}_{cluster})"
required: false
default: ""
registry_location:
description: "Region or multi-region of the Artifact Registry instance"
required: false
default: ""
runs:
using: "composite"
steps:
- shell: bash
run: |
set -ex
# Install gke-auth:
# - if version is "tip", `go install` from tip of main.
# - if version is "latest-release", look up latest release.
# - otherwise, install the specified version.
case ${{ inputs.version }} in
tip)
echo "Installing gke-auth using go install"
go install github.com/imjasonh/gke-auth@main
;;
latest-release)
tag=$(curl -s -u "username:${{ github.token }}" https://api.github.com/repos/imjasonh/gke-auth/releases/latest | jq -r '.tag_name')
;;
*)
tag="${{ inputs.version }}"
esac
if [[ ! -z ${tag} ]]; then
echo "Installing gke-auth @ ${tag}"
curl -fsL https://github.com/imjasonh/gke-auth/releases/download/${tag}/gke-auth_${tag:1}_Linux_x86_64.tar.gz | sudo tar xzf - -C /usr/local/bin gke-auth
fi
if [[ "${{ inputs.registry_location }}" != "" ]]; then
gke-auth --location=${{ inputs.registry_location }} --configure-docker
fi
args=(
--project=${{ inputs.project }}
--location=${{ inputs.location }}
--cluster=${{ inputs.cluster }}
)
if [[ "${{ inputs.alias }}" != "" ]]; then
args+=(--alias=${{ inputs.alias }})
fi
gke-auth "${args[@]}"