Skip to content
This repository was archived by the owner on Sep 16, 2025. It is now read-only.

Refactor Kubernetes manifests to include labels for better resource m… #4

Refactor Kubernetes manifests to include labels for better resource m…

Refactor Kubernetes manifests to include labels for better resource m… #4

Workflow file for this run

name: Deploy to Kubernetes
on:
push:
branches:
- main
- dev
env:
IMAGE_NAME: ghcr.io/${{ github.repository }}:${{ github.sha }}
jobs:
build-and-push:
runs-on: self-hosted
permissions:
contents: read
packages: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ env.IMAGE_NAME }}
deploy:
runs-on: ubuntu-latest
needs: build-and-push
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Kubeconfig
env:
KUBECONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
run: |
mkdir -p ~/.kube
# Decode and write kubeconfig
echo "${KUBECONFIG_DATA}" | base64 -d > ~/.kube/config
# Verify kubeconfig was decoded properly
if [ ! -s ~/.kube/config ]; then
echo "❌ ERROR: Kubeconfig file is empty after decoding!"
echo "Please verify that KUBECONFIG_DATA secret contains valid base64 encoded kubeconfig"
exit 1
fi
# Set proper permissions
chmod 600 ~/.kube/config
# Verify connection
echo "Testing connection to Kubernetes cluster..."
kubectl cluster-info
- name: Deploy to Kubernetes
run: |
if [ "${{ github.ref_name }}" = "main" ]; then
OVERLAY=main
elif [ "${{ github.ref_name }}" = "dev" ]; then
OVERLAY=dev
else
echo "Branch is not main or dev, skipping deployment."
exit 1
fi
cd k8s/overlays/$OVERLAY
kustomize build . | kubectl apply --prune -l app=public-wiki -f -