From 0f1a0b98f4bbf416dab6313d07fef14d78fc0829 Mon Sep 17 00:00:00 2001 From: gewuyou Date: Sat, 19 Jul 2025 20:10:20 +0800 Subject: [PATCH] =?UTF-8?q?ci:=E4=BC=98=E5=8C=96=20CI/CD=E5=B7=A5=E4=BD=9C?= =?UTF-8?q?=E6=B5=81=E7=A8=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 修改 main 分支的 tag、publish 和 mirror-to-github 阶段规则,排除 ci:、chore: 和 [no-publish] 前缀的提交 - 更新 test 分支的 publish 阶段规则,仅在 push 或 merge_request_event事件时触发 --- .gitlab/workflows/.gitlab-ci.main.yml | 7 +++---- .gitlab/workflows/.gitlab-ci.test.yml | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.gitlab/workflows/.gitlab-ci.main.yml b/.gitlab/workflows/.gitlab-ci.main.yml index ef93ac3..5f03320 100644 --- a/.gitlab/workflows/.gitlab-ci.main.yml +++ b/.gitlab/workflows/.gitlab-ci.main.yml @@ -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"' diff --git a/.gitlab/workflows/.gitlab-ci.test.yml b/.gitlab/workflows/.gitlab-ci.test.yml index 46a1b92..397ccd8 100644 --- a/.gitlab/workflows/.gitlab-ci.test.yml +++ b/.gitlab/workflows/.gitlab-ci.test.yml @@ -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