Some checks failed
Bump Version (via reusable workflow) / bump-version (push) Failing after 0s
77 lines
2.2 KiB
YAML
77 lines
2.2 KiB
YAML
name: Deploy Image to Kubernetes
|
|
run-name: ${{ gitea.actor }} deploys to k8s
|
|
|
|
on:
|
|
workflow_call:
|
|
inputs:
|
|
tag:
|
|
description: Image tag to deploy (e.g. v1.2.3)
|
|
type: string
|
|
required: true
|
|
deployment:
|
|
description: Kubernetes Deployment name
|
|
type: string
|
|
default: oumta-app
|
|
container:
|
|
description: Container name in the Deployment to update
|
|
type: string
|
|
default: app
|
|
namespace:
|
|
description: Kubernetes namespace
|
|
type: choice
|
|
default: oumta-dev
|
|
options:
|
|
- oumta-dev
|
|
- oumta-beta
|
|
- oumta-app
|
|
registry:
|
|
description: Container registry hostname (defaults to secret REGISTRY)
|
|
type: string
|
|
default: ""
|
|
image_name:
|
|
description: Full image name including registry (defaults to REGISTRY/repo)
|
|
type: string
|
|
default: ""
|
|
secrets:
|
|
KUBECONFIG:
|
|
description: Kubeconfig content
|
|
required: true
|
|
REGISTRY:
|
|
description: Container registry hostname
|
|
required: false
|
|
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
env:
|
|
REGISTRY: ${{ inputs.registry != '' && inputs.registry || secrets.REGISTRY }}
|
|
IMAGE_NAME: ${{ inputs.image_name }}
|
|
REPO: ${{ gitea.repository }}
|
|
steps:
|
|
- name: Install kubectl
|
|
uses: azure/setup-kubectl@v4
|
|
|
|
- name: Resolve image name
|
|
run: |
|
|
if [ -z "${IMAGE_NAME}" ]; then
|
|
IMAGE_NAME="${REGISTRY}/${REPO}"
|
|
fi
|
|
echo "IMAGE_NAME=${IMAGE_NAME}" >> "$GITHUB_ENV"
|
|
|
|
- name: Configure kubeconfig
|
|
env:
|
|
KUBECONFIG_CONTENT: ${{ secrets.KUBECONFIG }}
|
|
run: |
|
|
mkdir -p ~/.kube
|
|
printf '%s' "$KUBECONFIG_CONTENT" > ~/.kube/config
|
|
chmod 600 ~/.kube/config
|
|
|
|
- name: Update deployment image
|
|
run: |
|
|
IMAGE="${IMAGE_NAME}:${{ inputs.tag }}"
|
|
kubectl set image deployment/${{ inputs.deployment }} \
|
|
${{ inputs.container }}=${IMAGE} \
|
|
--namespace ${{ inputs.namespace }}
|
|
kubectl rollout status deployment/${{ inputs.deployment }} \
|
|
--namespace ${{ inputs.namespace }}
|