First restoring.
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled

This commit is contained in:
gitmuhammedalbayrak
2025-11-24 02:49:02 +03:00
parent cf05dbe943
commit a27dd3c675
3 changed files with 163 additions and 19 deletions

View File

@@ -1,49 +1,82 @@
name: Build and Deploy
run-name: ${{ gitea.actor }} Build and Deploy 🚀
on:
push:
branches:
- main
jobs:
build-push:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
- name: Checkout Code
uses: actions/checkout@v3
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
# -----------------------------------------------------------------
# CI PART
# -----------------------------------------------------------------
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to Gitea Registry
uses: docker/login-action@v2
- name: Docker Login (Gitea Registry)
uses: docker/login-action@v3
with:
registry: ${{ vars.GITEA_REGISTRY_URL }}
username: ${{ secrets.GITEA_REGISTRY_USERNAME }}
password: ${{ secrets.GITEA_REGISTRY_PASSWORD }}
# BACKEND BUILD & PUSH
- name: Build and Push Backend
uses: docker/build-push-action@v4
id: docker_build_backend
uses: docker/build-push-action@v5
with:
context: ./backend
push: true
tags: ${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/backend:latest
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
# FRONTEND BUILD & PUSH
- name: Build and Push Frontend
uses: docker/build-push-action@v4
id: docker_build_frontend
uses: docker/build-push-action@v5
with:
context: ./frontend
push: true
tags: ${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/frontend:latest
platforms: linux/amd64,linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Deploy to K3s
uses: actions-hub/kubectl@master
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
with:
args: rollout restart deployment/evrak-backend deployment/evrak-frontend
# -----------------------------------------------------------------
# CD PART
# -----------------------------------------------------------------
- name: Install Kubectl Binary
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/arm64/kubectl"
chmod +x kubectl
sudo mv kubectl /usr/local/bin/
- name: Deploy to Kubernetes and Update
run: |
# 1. Write Kubeconfig content to file
echo "${{ secrets.KUBE_CONFIG }}" > /tmp/kubeconfig.yaml
# 2. Get the new image Digests
BACKEND_DIGEST="${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/backend@${{ steps.docker_build_backend.outputs.digest }}"
FRONTEND_DIGEST="${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/frontend@${{ steps.docker_build_frontend.outputs.digest }}"
# 3. Update Deployment
kubectl set image deployment/evrak-backend backend=${BACKEND_DIGEST} \
--kubeconfig=/tmp/kubeconfig.yaml -n default
kubectl set image deployment/evrak-frontend frontend=${FRONTEND_DIGEST} \
--kubeconfig=/tmp/kubeconfig.yaml -n default
# 4. Rollout Restart to ensure fresh pods
kubectl rollout restart deployment/evrak-backend \
--kubeconfig=/tmp/kubeconfig.yaml -n default
kubectl rollout restart deployment/evrak-frontend \
--kubeconfig=/tmp/kubeconfig.yaml -n default