Files
dashboard-backend/.gitea/workflows/build-deploy.yml
CloudForge Dev 0aa45f913b
Some checks failed
Build and Deploy Backend / build-and-deploy (push) Failing after 6s
Add kubectl installation 2
2025-11-19 16:33:03 +08:00

60 lines
1.9 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

name: Build and Deploy Backend
on:
push:
branches:
- main
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install kubectl + Build with Kaniko + Deploy
# 用 bitnami/kubectl image呢個 image 入面有 curl, bash, kubectl
container:
image: bitnami/kubectl:latest
run: |
# ---- 下載 kubectl 前先檢查已存在版本 ----
kubectl version --client
# ---- Kaniko Job ----
kubectl apply -f - <<EOJOB
apiVersion: batch/v1
kind: Job
metadata:
name: build-backend-\${GITHUB_SHA:0:8}
namespace: cloudforge
spec:
ttlSecondsAfterFinished: 600
template:
spec:
containers:
- name: kaniko
image: gcr.io/kaniko-project/executor:v1.9.0
args:
- "--dockerfile=Dockerfile"
- "--context=git://gitea-http.gitea.svc.cluster.local:3000/cloudforge-dev/dashboard-backend.git#main"
- "--destination=cloudforge-dashboard-backend:\${GITHUB_SHA:0:8}"
- "--destination=cloudforge-dashboard-backend:latest"
- "--insecure"
- "--skip-tls-verify"
- "--no-push"
restartPolicy: Never
EOJOB
# ---- Wait Kaniko Build----
kubectl wait --for=condition=complete --timeout=600s job/build-backend-\${GITHUB_SHA:0:8} -n cloudforge
# ---- Deploy Backend ----
kubectl set image deployment/dashboard-backend backend=cloudforge-dashboard-backend:\${GITHUB_SHA:0:8} -n cloudforge --record
# ---- Verify Deployment ----
kubectl rollout status deployment/dashboard-backend -n cloudforge --timeout=300s
# ---- Cleanup ----
kubectl delete job build-backend-\${GITHUB_SHA:0:8} -n cloudforge