Files
evrak/.gitea/workflows/deploy.yaml
gitmuhammedalbayrak 2fbefaf9c0
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
feat: Add Gitea Actions workflow for building Docker images and deploying with Helm.
2025-11-24 04:35:11 +03:00

84 lines
3.3 KiB
YAML

name: Build and Deploy
run-name: ${{ gitea.actor }} Build and Deploy 🚀
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v3
# -----------------------------------------------------------------
# CI PART - Test
# -----------------------------------------------------------------
- name: Setup Docker Buildx
uses: docker/setup-buildx-action@v3
- 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
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
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
# -----------------------------------------------------------------
# CD PART (HELM)
# -----------------------------------------------------------------
- name: Install Kubectl & Helm
run: |
# Install kubectl (ARM64)
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/
# Install Helm
curl https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | bash
- name: Deploy with Helm
run: |
# 1. Write Kubeconfig content to file
echo "${{ secrets.KUBE_CONFIG }}" > /tmp/kubeconfig.yaml
# 2. Deploy using Helm Upgrade
# We pass the image repository and tag explicitly to ensure we use the Gitea registry
helm upgrade --install evrak ./deploy/charts/evrak \
--kubeconfig /tmp/kubeconfig.yaml \
--namespace default \
--set backend.image.repository=${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/backend \
--set backend.image.tag=latest \
--set frontend.image.repository=${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/frontend \
--set frontend.image.tag=latest \
--set postgres.auth.password=${{ secrets.DB_PASSWORD }}
# 3. Force restart to pick up latest image if tag is 'latest' (Helm doesn't always redeploy if values didn't change)
kubectl rollout restart deployment/evrak-backend --kubeconfig /tmp/kubeconfig.yaml -n default
kubectl rollout restart deployment/evrak-frontend --kubeconfig /tmp/kubeconfig.yaml -n default