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

View File

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