Some checks failed
Build and Deploy Backend / build-and-deploy (push) Failing after 9s
68 lines
1.9 KiB
YAML
68 lines
1.9 KiB
YAML
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
|
|
run: |
|
|
curl -LO "https://dl.k8s.io/release/v1.28.0/bin/linux/amd64/kubectl"
|
|
chmod +x kubectl
|
|
mkdir -p ~/.local/bin
|
|
mv kubectl ~/.local/bin/
|
|
export PATH=$PATH:~/.local/bin
|
|
|
|
- name: Configure kubectl
|
|
run: |
|
|
# Runner 應該有 in-cluster config
|
|
# 或者用 service account token
|
|
kubectl cluster-info
|
|
|
|
- name: Build with Kaniko
|
|
run: |
|
|
~/.local/bin/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:latest"
|
|
- "--insecure"
|
|
- "--skip-tls-verify"
|
|
- "--no-push"
|
|
restartPolicy: Never
|
|
EOJOB
|
|
|
|
- name: Wait and Deploy
|
|
run: |
|
|
~/.local/bin/kubectl wait --for=condition=complete \
|
|
--timeout=600s \
|
|
job/build-backend-${GITHUB_SHA:0:8} \
|
|
-n cloudforge
|
|
|
|
~/.local/bin/kubectl set image deployment/dashboard-backend \
|
|
backend=cloudforge-dashboard-backend:latest \
|
|
-n cloudforge
|
|
|
|
~/.local/bin/kubectl rollout status deployment/dashboard-backend \
|
|
-n cloudforge
|