This commit is contained in:
44
.gitea/workflows/deploy.yml
Normal file
44
.gitea/workflows/deploy.yml
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
name: Deploy to K3s
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout code
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Build and push backend image
|
||||||
|
run: |
|
||||||
|
cd apps/backend
|
||||||
|
docker build -t localhost:5000/backend:latest .
|
||||||
|
docker push localhost:5000/backend:latest
|
||||||
|
|
||||||
|
- name: Build and push frontend image
|
||||||
|
run: |
|
||||||
|
cd apps/frontend
|
||||||
|
docker build \
|
||||||
|
--build-arg API_BASE="http://backend-service:3001" \
|
||||||
|
-t localhost:5000/frontend:latest .
|
||||||
|
docker push localhost:5000/frontend:latest
|
||||||
|
|
||||||
|
- name: Deploy to K3s
|
||||||
|
run: |
|
||||||
|
cd apps/deploy
|
||||||
|
|
||||||
|
# 应用基础设施配置(Secrets 已手动创建,YAML 中不含敏感数据)
|
||||||
|
kubectl apply -f postgres-deployment.yaml
|
||||||
|
kubectl apply -f backend-deployment.yaml
|
||||||
|
kubectl apply -f frontend-deployment.yaml
|
||||||
|
|
||||||
|
# 强制滚动更新以加载新镜像(因使用 latest 标签)
|
||||||
|
kubectl rollout restart deployment/backend
|
||||||
|
kubectl rollout restart deployment/frontend
|
||||||
|
|
||||||
|
# 可选:等待部署完成(增强可靠性)
|
||||||
|
kubectl rollout status deployment/backend --timeout=120s
|
||||||
|
kubectl rollout status deployment/frontend --timeout=120s
|
||||||
Reference in New Issue
Block a user