Files
evrak/.gitea/workflows/deploy.yaml
gitmuhammedalbayrak afd85966e8
Some checks failed
Build and Deploy / build-and-deploy (push) Has been cancelled
feat: Implement initial Helm charts for backend and frontend, Gitea CI/CD pipeline, and Coder workspace configuration.
2025-12-03 23:53:38 +03:00

84 lines
3.6 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
# -----------------------------------------------------------------
# -----------------------------------------------------------------
# CI PART (Kaniko)
# -----------------------------------------------------------------
- name: Create Docker Config
run: |
mkdir -p ${{ github.workspace }}/.docker
echo "{\"auths\":{\"${{ vars.GITEA_REGISTRY_URL }}\":{\"username\":\"${{ secrets.GITEA_REGISTRY_USERNAME }}\",\"password\":\"${{ secrets.GITEA_REGISTRY_PASSWORD }}\"}}}" > ${{ github.workspace }}/.docker/config.json
# BACKEND BUILD & PUSH
- name: Build and Push Backend
uses: docker://gcr.io/kaniko-project/executor:v1.14.0-debug
env:
DOCKER_CONFIG: /github/workspace/.docker
with:
args: >
--context=dir:///github/workspace/backend
--dockerfile=Dockerfile
--destination=${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/backend:latest
--cache=true
--custom-platform=linux/arm64
# FRONTEND BUILD & PUSH
- name: Build and Push Frontend
uses: docker://gcr.io/kaniko-project/executor:v1.14.0-debug
env:
DOCKER_CONFIG: /github/workspace/.docker
with:
args: >
--context=dir:///github/workspace/frontend
--dockerfile=Dockerfile
--destination=${{ vars.GITEA_REGISTRY_URL }}/${{ github.repository }}/frontend:latest
--cache=true
--custom-platform=linux/arm64
# -----------------------------------------------------------------
# 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