Files
slogan/.gitea/workflows/dev-deploy.yaml
T
2026-08-04 16:24:30 +08:00

39 lines
1.6 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.
# ============================================================
# ai-agent dev 分支自动发布
# 触发:push dev 分支
# 流程:构建镜像 -> push 本地仓库(127.0.0.1:5000) -> 部署到 dev 宿主机本地 k3s
# 前置:runner 挂载 dev k3s kubeconfig 到 /root/.kube/k3s-dev.yaml
# ============================================================
name: Deploy ai-agent to dev k3s
on:
push:
branches: [ master ]
jobs:
build-and-deploy:
runs-on: ubuntu-latest
steps:
# 不依赖 actions/checkout(从 github.com 拉 action 源码,国内网络不稳定),
# 直接 clone 本地 Gitea,用 Actions 注入的 GITHUB_TOKEN 认证
- name: 拉取代码
run: |
git clone --branch dev http://x-access-token:${GITHUB_TOKEN}@127.0.0.1:3000/red-future/ai-agent.git .
git checkout ${GITHUB_SHA}
- name: 构建并推送镜像
run: |
TAG=dev-${GITHUB_SHA::8}
# context 为仓库根:镜像内含 Flutter web 前端(Dockerfile web-builder stage
docker build -t 127.0.0.1:5000/ai-agent:${TAG} -f server/Dockerfile .
docker push 127.0.0.1:5000/ai-agent:${TAG}
- name: 部署到 dev k3s
env:
KUBECONFIG: /root/.kube/k3s-dev.yaml
run: |
kubectl create namespace dev --dry-run=client -o yaml | kubectl apply -f -
kubectl apply -f deploy/k8s/ai-agent.yaml
kubectl set image deployment/ai-agent ai-agent=127.0.0.1:5000/ai-agent:dev-${GITHUB_SHA::8} -n dev
kubectl rollout status deployment/ai-agent -n dev --timeout=5m