47428a8b58
build / build (push) Successful in 1m27s
将发布人的状态变更与业务验收报告绑定,复用 Gitea 发布及回滚链路。 从部署回执写入运行身份、镜像及主站登录入口,避免重复调度和回写。
83 lines
2.7 KiB
YAML
83 lines
2.7 KiB
YAML
name: deploy-production
|
|
|
|
on:
|
|
workflow_dispatch:
|
|
inputs:
|
|
action:
|
|
description: deploy 或 writeback
|
|
required: true
|
|
default: deploy
|
|
sha:
|
|
description: 验收过的完整提交 SHA
|
|
required: true
|
|
bundle:
|
|
description: release.json 的完整 SHA256
|
|
required: true
|
|
task:
|
|
description: 对应的 HiFox 任务 UUID
|
|
required: true
|
|
confirm:
|
|
description: deploy-production 或 retry-writeback
|
|
required: true
|
|
approval_event:
|
|
description: HiFox 自动触发填写的状态事件 UUID
|
|
required: false
|
|
acceptance_digest:
|
|
description: HiFox 自动触发填写的验收记录摘要
|
|
required: false
|
|
|
|
concurrency:
|
|
group: cloud-test-governance-main-production
|
|
cancel-in-progress: false
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
jobs:
|
|
guard:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 5
|
|
steps:
|
|
- name: 核对手动入口及发布输入
|
|
run: |
|
|
set -eu
|
|
test "$GITHUB_EVENT_NAME" = workflow_dispatch
|
|
test "$GITHUB_REPOSITORY" = Weknora/knowledge-governance
|
|
test "$GITHUB_REF" = refs/heads/main
|
|
case "$GITHUB_SERVER_URL" in
|
|
https://gitea.zheromiku.top|http://192.168.50.223:3000) ;;
|
|
*) exit 1 ;;
|
|
esac
|
|
git init -q .
|
|
git fetch -q --depth 200 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git" refs/heads/main
|
|
git checkout -q --detach "$GITHUB_SHA"
|
|
test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
|
|
python3 scripts/production_cd.py guard --event "$GITHUB_EVENT_PATH"
|
|
|
|
publish:
|
|
needs: [guard]
|
|
runs-on: kg-production-cd
|
|
timeout-minutes: 40
|
|
steps:
|
|
- name: 取同一提交的控制端代码
|
|
run: |
|
|
set -eu
|
|
test "$GITHUB_EVENT_NAME" = workflow_dispatch
|
|
test "$GITHUB_REPOSITORY" = Weknora/knowledge-governance
|
|
test "$GITHUB_REF" = refs/heads/main
|
|
case "$GITHUB_SERVER_URL" in
|
|
https://gitea.zheromiku.top|http://192.168.50.223:3000) ;;
|
|
*) exit 1 ;;
|
|
esac
|
|
git init -q .
|
|
git fetch -q --depth 200 "$GITHUB_SERVER_URL/$GITHUB_REPOSITORY.git" refs/heads/main
|
|
git checkout -q --detach "$GITHUB_SHA"
|
|
test "$(git rev-parse HEAD)" = "$GITHUB_SHA"
|
|
- name: 调用云主站受限发布入口并读回回执
|
|
env:
|
|
KG_CD_SSH_KEY: ${{ secrets.KG_CD_SSH_KEY }}
|
|
KG_CD_KNOWN_HOSTS: ${{ secrets.KG_CD_KNOWN_HOSTS }}
|
|
KG_CD_SSH_HOST: ${{ vars.KG_CD_SSH_HOST }}
|
|
KG_CD_SSH_PORT: ${{ vars.KG_CD_SSH_PORT }}
|
|
run: python3 scripts/production_cd.py send --event "$GITHUB_EVENT_PATH"
|