Update k8s manifest

This commit is contained in:
2024-11-04 17:36:01 +11:00
parent 4cbdf35cfc
commit cf920f0907
2 changed files with 91 additions and 4 deletions
+6 -4
View File
@@ -2,12 +2,12 @@ name: Build and Deploy to Kubernetes
on:
push:
branches: [ main ] # Trigger the action on push to main branch
branches: [ main ]
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
K8S_NAMESPACE: default # Replace with your Kubernetes namespace
K8S_NAMESPACE: apps
jobs:
build-and-deploy:
@@ -33,10 +33,12 @@ jobs:
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
# Build and push main application image
- name: Build and push Docker image
uses: docker/build-push-action@v3
with:
context: .
file: Dockerfile
push: true
tags: |-
${{ steps.meta.outputs.tags }}
@@ -50,7 +52,7 @@ jobs:
KUBE_CONFIG_DATA: ${{ secrets.KUBE_CONFIG_DATA }}
with:
args: |-
# Update the deployment.yaml with the new image tag
# Update both deployments with new image tags
sed -i 's|image: .*|image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:1.0.${{ github.run_number }}|' k8s/manifest.yaml
# Apply Kubernetes manifests
kubectl apply -n apps -f k8s/manifest.yaml
kubectl apply -n ${{ env.K8S_NAMESPACE }} -f k8s/manifest.yaml