58 lines
1.8 KiB
YAML
58 lines
1.8 KiB
YAML
name: Build with Kaniko
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Build Backend with Kaniko
|
|
uses: docker://gcr.io/kaniko-project/executor:latest
|
|
with:
|
|
args: >
|
|
--context=dir://./dashboard-backend
|
|
--dockerfile=./dashboard-backend/Dockerfile
|
|
--destination=cloudforge-dashboard-backend:${{ github.sha }}
|
|
--destination=cloudforge-dashboard-backend:latest
|
|
--no-push
|
|
--tar-path=/workspace/backend.tar
|
|
|
|
- name: Build Frontend with Kaniko
|
|
uses: docker://gcr.io/kaniko-project/executor:latest
|
|
with:
|
|
args: >
|
|
--context=dir://./dashboard-frontend
|
|
--dockerfile=./dashboard-frontend/Dockerfile
|
|
--destination=cloudforge-dashboard-frontend:${{ github.sha }}
|
|
--destination=cloudforge-dashboard-frontend:latest
|
|
--no-push
|
|
--tar-path=/workspace/frontend.tar
|
|
|
|
- name: Load images to containerd
|
|
run: |
|
|
# Import 到 K3S
|
|
ctr -n k8s.io images import /workspace/backend.tar
|
|
ctr -n k8s.io images import /workspace/frontend.tar
|
|
|
|
- name: Deploy with kubectl
|
|
run: |
|
|
kubectl set image deployment/dashboard-backend \
|
|
backend=cloudforge-dashboard-backend:${{ github.sha }} \
|
|
-n cloudforge || echo "Deployment not found, will create"
|
|
|
|
kubectl set image deployment/dashboard-frontend \
|
|
frontend=cloudforge-dashboard-frontend:${{ github.sha }} \
|
|
-n cloudforge || echo "Deployment not found, will create"
|
|
|
|
- name: Verify
|
|
run: |
|
|
kubectl rollout status deployment/dashboard-backend -n cloudforge -t 300s
|
|
kubectl rollout status deployment/dashboard-frontend -n cloudforge -t 300s
|