ci:优化 CI/CD工作流程

- 修改 main 分支的 tag、publish 和 mirror-to-github 阶段规则,排除 ci:、chore: 和 [no-publish] 前缀的提交
- 更新 test 分支的 publish 阶段规则,仅在 push 或 merge_request_event事件时触发
This commit is contained in:
gewuyou 2025-07-19 20:10:20 +08:00
parent 7235f06856
commit 0f1a0b98f4
2 changed files with 4 additions and 5 deletions

View File

@ -15,7 +15,7 @@ tag:
stage: tag
image: alpine:latest
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
- if: '$CI_COMMIT_BRANCH == "main" && $CI_COMMIT_MESSAGE !~ /^ci:|^chore:|^\[no-publish\]/'
script:
- set -euo pipefail
- apk add --no-cache git
@ -55,7 +55,7 @@ publish:
stage: publish
needs: [ "tag" ]
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
- if: '$CI_COMMIT_BRANCH == "main" && $CI_COMMIT_MESSAGE !~ /^ci:|^chore:|^\[no-publish\]/'
cache:
key:
files:
@ -81,7 +81,7 @@ reset:
needs: [ "publish" ]
image: alpine:latest
rules:
- if: '$CI_COMMIT_BRANCH == "main"'
- if: '$CI_COMMIT_BRANCH == "main" && $CI_COMMIT_MESSAGE !~ /^ci:|^chore:|^\[no-publish\]/'
script:
- set -euo pipefail
- apk add --no-cache git
@ -97,7 +97,6 @@ reset:
# Mirror to GitHub
mirror-to-github:
stage: mirror
needs: [ "publish" ]
image: alpine:latest
rules:
- if: '$CI_COMMIT_BRANCH == "main"'

View File

@ -5,7 +5,7 @@ stages:
publish:
stage: publish
rules:
- if: '$CI_COMMIT_BRANCH == "test"'
- if: '$CI_COMMIT_BRANCH == "test" && ($CI_PIPELINE_SOURCE == "push" || $CI_PIPELINE_SOURCE == "merge_request_event")'
script:
- echo "🔧 授予 gradlew 执行权限..."
- chmod +x gradlew