Files
pipeline-actions/deploy-restart/action.yaml
Jose Henrique fc7ed6bd15
Some checks failed
Test build-and-push (self-test) / Build tiny multi-arch image (push) Failing after 2s
fix: strip CRLF from inputs + add .gitattributes (eol=lf) -- fixes ssh username 'invalid characters'
2026-07-13 19:39:29 -03:00

69 lines
2.1 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: |
# strip stray CR (CRLF checkout via core.autocrlf)
printf '%s' "${KUBE_CONFIG}" | tr -d '\r' > 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}"