- build-and-push: multi-arch Docker build via remote Buildx builder over SSH - deploy-restart: kubectl rollout restart with kubeconfig validation - README with usage examples and required secrets
68 lines
2.0 KiB
YAML
68 lines
2.0 KiB
YAML
name: Deploy Restart (kubectl rollout)
|
|
description: Validate KUBE_CONFIG, install kubectl, and perform a rollout restart of a Kubernetes deployment.
|
|
|
|
inputs:
|
|
kube_config:
|
|
description: Full kubeconfig YAML content (pass via secrets)
|
|
required: true
|
|
deployment_name:
|
|
description: Name of the Kubernetes Deployment to restart
|
|
required: true
|
|
namespace:
|
|
description: Kubernetes namespace of the deployment
|
|
required: false
|
|
default: default
|
|
kube_version:
|
|
description: Kubernetes version to download (stable, or a specific version like v1.31.0)
|
|
required: false
|
|
default: stable
|
|
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Check KUBE_CONFIG validity
|
|
shell: bash
|
|
env:
|
|
KUBE_CONFIG: ${{ inputs.kube_config }}
|
|
run: |
|
|
if [ -z "${KUBE_CONFIG}" ] || [ "${KUBE_CONFIG}" = "" ] || [ "${KUBE_CONFIG// }" = "" ]; then
|
|
echo "KUBE_CONFIG is not set or is empty."
|
|
exit 1
|
|
fi
|
|
|
|
- name: Check out repository
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Download and install kubectl
|
|
shell: bash
|
|
env:
|
|
KUBE_VERSION: ${{ inputs.kube_version }}
|
|
run: |
|
|
apt-get update -y
|
|
apt-get install -y curl
|
|
if [ "${KUBE_VERSION}" = "stable" ]; then
|
|
KUBE_VER="$(curl -L -s https://dl.k8s.io/release/stable.txt)"
|
|
else
|
|
KUBE_VER="${KUBE_VERSION}"
|
|
fi
|
|
curl -LO "https://dl.k8s.io/release/${KUBE_VER}/bin/linux/amd64/kubectl"
|
|
install -m 0755 kubectl /usr/local/bin/kubectl
|
|
kubectl version --client
|
|
|
|
- name: Set up kubeconfig
|
|
shell: bash
|
|
env:
|
|
KUBE_CONFIG: ${{ inputs.kube_config }}
|
|
run: |
|
|
echo "${KUBE_CONFIG}" > kubeconfig.yaml
|
|
kubectl --kubeconfig=kubeconfig.yaml cluster-info
|
|
|
|
- name: Rollout restart
|
|
shell: bash
|
|
env:
|
|
DEPLOYMENT_NAME: ${{ inputs.deployment_name }}
|
|
NAMESPACE: ${{ inputs.namespace }}
|
|
run: |
|
|
kubectl --kubeconfig=kubeconfig.yaml rollout restart \
|
|
deployment "${DEPLOYMENT_NAME}" -n "${NAMESPACE}"
|