Files
UserBaseService/.gitea/workflows/deploy.yml
T
chenxing c9a30b473d
deploy-userbase-service / build-deploy (push) Failing after 33s
fix: maven-settings overrides HTTP blocker; cache ~/.m2 on host
2026-08-05 11:19:14 +08:00

44 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: deploy-userbase-service
on:
push:
branches: [main]
workflow_dispatch:
jobs:
build-deploy:
runs-on: ubuntu-latest
# docker:24 自带 docker CLI;宿主 docker.sock 默认挂入 job 容器,
# 因此 docker build/push/run 实际都在宿主守护进程上执行。
container:
image: docker:24
steps:
- name: Install git (alpine)
run: apk add --no-cache git
- name: Checkout (manual, internal Gitea)
run: |
git clone --depth 1 --branch main http://192.168.10.160:3000/${GITHUB_REPOSITORY}.git /tmp/src
cp -a /tmp/src/. .
rm -rf .git .gitea
rm -rf /tmp/src
# 用宿主 docker 守护进程跑 maven(--network=host 走宿主外网拉依赖),
# 产出 target/userbase.jar 落到工作区。
- name: Build jar (maven, host network, nexus maven-public)
# maven-settings.xml 将 central 指向 nexus maven-public(含内部 SNAPSHOT BOM 与 central 代理)
# 挂载宿主 /opt/docker/ubs-m2 作为 maven 本地仓库缓存,加速重复构建
run: docker run --rm --network=host -v $PWD:/build -v /opt/docker/ubs-m2:/root/.m2 -w /build maven:3.9-eclipse-temurin-8 mvn -s maven-settings.xml -B -DskipTests package
- name: Build image on host daemon
run: docker build -f docker/Dockerfile -t userbase-service:latest .
- name: Deploy on host (infra-infra-net)
# 镜像已在宿主本地,直接运行,无需推送到 nexus(nexus docker 仓库为 HTTP,需 daemon insecure-registries 才能推送)
run: |
docker rm -f userbase-service 2>/dev/null || true
docker run -d --name userbase-service --network infra-infra-net -p 8060:8060 --restart unless-stopped userbase-service:latest
- name: Done
run: 'echo "UserBaseService deployed -> http://192.168.10.160:8060/userbase"'