Files
CasSsoService/.gitea/workflows/deploy.yml
T
2026-08-31 17:29:16 +08:00

48 lines
2.2 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: build-push
# CAS 接入 projman 部署平台后:本 workflow 只负责 构建镜像 + 推 Nexus + 通知 projman 建档,
# 部署由运维在 projman「后端发布」tab 手动选 tag 执行(App.deployMode=manual)。
# 触发:push 到 main / 手动 Run workflow
# 依赖仓库 Secrets:NEXUS_USER / NEXUS_PASSWORD(docker-hosted 推送)/ DEPLOY_TOKEN(webhook 鉴权)/ WEBHOOK_URL
# 镜像名与 projman 派生规则一致:应用名 cassso → 镜像 cassso-service(NexusClient.imageRepo = 应用名小写 + "-service")
# 注意:nexus:8083 为 HTTP 仓库,宿主 daemon 需配置 insecure-registries 才能推送(projman 一直在拉,通常已配)
on:
push:
branches: [main]
workflow_dispatch:
jobs:
build-push:
runs-on: ubuntu-latest
# docker:24 自带 docker CLI;宿主 docker.sock 默认挂入 job 容器
container:
image: docker:24
steps:
- name: Install git / curl (alpine)
run: apk add --no-cache git curl
- name: Checkout (manual, internal Gitea)
# cas.war (约 170MB) 已作为普通 blob 入库(服务端未启用 LFS)
run: |
git clone --depth 1 --branch main http://192.168.10.160:3000/${GITHUB_REPOSITORY}.git /tmp/src
COMMIT_MSG=$(git -C /tmp/src log -1 --pretty=%s | tr '\n' ' ' | sed 's/["\\]/ /g' | cut -c1-200)
echo "COMMIT_MSG=${COMMIT_MSG}" >> "$GITHUB_ENV"
cp -a /tmp/src/. .
rm -rf .git .gitea /tmp/src
- name: Build image (copies docker/cas.war, host daemon)
run: docker build -f docker/Dockerfile -t nexus:8083/docker-hosted/cassso-service:${GITHUB_SHA:0:8} .
- name: Push Nexus docker-hosted
run: |
echo "${{ secrets.NEXUS_PASSWORD }}" | docker login nexus:8083 -u "${{ secrets.NEXUS_USER }}" --password-stdin
docker push nexus:8083/docker-hosted/cassso-service:${GITHUB_SHA:0:8}
- name: Notify projman (release pending, manual deploy)
run: |
curl -sS -X POST "${{ secrets.WEBHOOK_URL }}" \
-H "Content-Type: application/json" \
-H "X-Deploy-Token: ${{ secrets.DEPLOY_TOKEN }}" \
-d "{\"app\":\"cassso\",\"tag\":\"${GITHUB_SHA:0:8}\",\"sha\":\"${GITHUB_SHA}\",\"message\":\"${COMMIT_MSG}\"}"