Files
JayuCloud/.gitea/workflows/环境分支晋级检查.yml
T
xiaowang 3ad792115c
环境分支晋级检查 / environment-promotion-source (pull_request_target) Successful in 1s
自动发布开发环境 Nacos 配置 / publish (push) Successful in 29s
fix(actions): use Chinese workflow filenames
2026-10-16 14:48:49 +08:00

44 lines
1.2 KiB
YAML

name: 环境分支晋级检查
on:
pull_request_target:
branches:
- sit
- prod
jobs:
validate-source:
name: environment-promotion-source
runs-on: jayucloud
steps:
- name: 校验环境分支晋级链路
shell: bash
env:
TARGET_BRANCH: ${{ gitea.base_ref }}
SOURCE_BRANCH: ${{ gitea.head_ref }}
SOURCE_REPOSITORY: ${{ gitea.event.pull_request.head.repo.full_name }}
TARGET_REPOSITORY: ${{ gitea.repository }}
run: |
set -euo pipefail
test -n "$TARGET_BRANCH"
test -n "$SOURCE_BRANCH"
test -n "$SOURCE_REPOSITORY"
test -n "$TARGET_REPOSITORY"
if [[ "$SOURCE_REPOSITORY" != "$TARGET_REPOSITORY" ]]; then
echo "拒绝跨仓库环境晋级:$SOURCE_REPOSITORY -> $TARGET_REPOSITORY"
exit 1
fi
case "$TARGET_BRANCH:$SOURCE_BRANCH" in
sit:dev|prod:sit)
echo "允许环境晋级:$SOURCE_BRANCH -> $TARGET_BRANCH"
;;
*)
echo "拒绝环境晋级:$SOURCE_BRANCH -> $TARGET_BRANCH"
echo "允许链路仅为 dev -> sit -> prod"
exit 1
;;
esac