From 3bdae16fb2e451bab1171776ec6290c6d9a661f2 Mon Sep 17 00:00:00 2001 From: liquidrinu Date: Thu, 22 May 2025 00:12:43 +0200 Subject: [PATCH] Move workflow to .gitea/workflows/demo.yaml --- .gitea-ci.yml | 14 ------ .gitea/workflows/demo.yaml | 97 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 97 insertions(+), 14 deletions(-) delete mode 100644 .gitea-ci.yml create mode 100644 .gitea/workflows/demo.yaml diff --git a/.gitea-ci.yml b/.gitea-ci.yml deleted file mode 100644 index a9cf0ce..0000000 --- a/.gitea-ci.yml +++ /dev/null @@ -1,14 +0,0 @@ -version: 1.0 - -workflow: - name: Test Runner - on: - push: - branches: - - main - -jobs: - test: - runs-on: general - steps: - - run: echo "Runner is working!" \ No newline at end of file diff --git a/.gitea/workflows/demo.yaml b/.gitea/workflows/demo.yaml new file mode 100644 index 0000000..fb445b2 --- /dev/null +++ b/.gitea/workflows/demo.yaml @@ -0,0 +1,97 @@ +version: 1.0 + +workflow: + name: Deploy to Production + on: + push: + branches: + - main + +jobs: + build-and-deploy: + name: Build and Deploy + runs-on: general + steps: + - name: Checkout code + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Registry + uses: docker/login-action@v2 + with: + registry: registry.liquidrinu.com + username: ${{ secrets.REGISTRY_USERNAME }} + password: ${{ secrets.REGISTRY_PASSWORD }} + + - name: Build and Push Backend + uses: docker/build-push-action@v4 + with: + context: ./backend + push: true + tags: registry.liquidrinu.com/fusero-backend:latest + cache-from: type=registry,ref=registry.liquidrinu.com/fusero-backend:buildcache + cache-to: type=registry,ref=registry.liquidrinu.com/fusero-backend:buildcache,mode=max + + - name: Build and Push Frontend + uses: docker/build-push-action@v4 + with: + context: ./frontend + push: true + tags: registry.liquidrinu.com/fusero-frontend:latest + cache-from: type=registry,ref=registry.liquidrinu.com/fusero-frontend:buildcache + cache-to: type=registry,ref=registry.liquidrinu.com/fusero-frontend:buildcache,mode=max + + - name: Install kubectl + uses: azure/setup-kubectl@v3 + with: + version: "latest" + + - name: Setup kubeconfig + run: | + mkdir -p $HOME/.kube + echo "${{ secrets.KUBE_CONFIG }}" | base64 -d > $HOME/.kube/config + chmod 600 $HOME/.kube/config + + - name: Create secrets file + run: | + cat > ./chart/secrets.prod.yaml << EOF + backend: + env: + POSTGRES_PASSWORD: "${{ secrets.POSTGRES_PASSWORD }}" + DEFAULT_ADMIN_PASSWORD: "${{ secrets.DEFAULT_ADMIN_PASSWORD }}" + ENCRYPTION_KEY: "${{ secrets.ENCRYPTION_KEY }}" + JWT_SECRET: "${{ secrets.JWT_SECRET }}" + CHATGPT_API_KEY: "${{ secrets.CHATGPT_API_KEY }}" + CANVAS_API_KEY: "${{ secrets.CANVAS_API_KEY }}" + EOF + + - name: Delete old migration/seed job + run: | + kubectl delete job fusero-backend-db-init -n fusero-prod || true + + - name: Deploy to Kubernetes + run: | + helm upgrade --install fusero ./chart \ + --namespace fusero-prod \ + --create-namespace \ + --values ./chart/values.prod.yaml \ + --values ./chart/secrets.prod.yaml \ + --set backend.image.repository=registry.liquidrinu.com/fusero-backend \ + --set frontend.image.repository=registry.liquidrinu.com/fusero-frontend + + - name: Wait for migration/seed job + run: | + kubectl wait --for=condition=complete --timeout=300s job/fusero-backend-db-init -n fusero-prod + JOB_STATUS=$(kubectl get job fusero-backend-db-init -n fusero-prod -o jsonpath='{.status.succeeded}') + if [ "$JOB_STATUS" != "1" ]; then + echo "Migration/seed job failed!" >&2 + kubectl logs job/fusero-backend-db-init -n fusero-prod + exit 1 + fi + + - name: Verify Deployment + run: | + kubectl rollout status deployment/fusero-backend -n fusero-prod + kubectl rollout status deployment/fusero-frontend -n fusero-prod