You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在Codemagic中避免Git推送触发重复构建循环?

跳过GitHub触发CI构建的解决方案
  • 方案1:提交信息添加跳过标识(最便捷,兼容性强)
    GitHub及Codemagic均默认支持识别提交信息中的跳过CI关键词,你只需要修改脚本中git commit的提交信息,添加[skip ci]标识即可,推送后不会触发新的构建流程,从根源打断循环。仅需修改提交行代码为:
    git commit -m "Bump version to $version [skip ci]" pubspec.yaml
    这个方案不需要修改任何CI配置,改动量最小。

  • 方案2:调整Codemagic触发过滤规则
    你可以在Codemagic的构建设置中添加触发过滤条件:

    • 过滤提交信息包含Bump version to的提交,不触发构建
    • 过滤前缀为dev-的标签推送,不触发构建
      双重过滤可以彻底避免自动提交触发的循环构建,适合需要保留提交信息原始格式的场景。
  • 方案3:修改推送鉴权方式(可选)
    使用GitHub部署密钥而非个人访问令牌进行推送,默认情况下部署密钥触发的推送不会触发GitHub Actions及关联的CI构建,不过需要额外配置仓库的部署密钥权限,适合不想修改提交信息也不想调整触发规则的场景。

修改后的完整构建脚本参考:

#!/usr/bin/env bash

set -e # exit on first failed command
set -x # print all executed commands to the log

#if [ "$FCI_BUILD_STEP_STATUS" = "success" ]
#then
  
  #bump code version
  perl -i -pe 's/^(version:\s+\d+\.\d+\.\d+\+)(\d+)$/$1.($2+1)/e' pubspec.yaml

  #create a tag and publish
  v=`grep 'version: ' pubspec.yaml | sed 's/version: //'`
  version="dev-$v"

  git commit -m "Bump version to $version [skip ci]" pubspec.yaml 

  git tag -a -m "Bump app version" $version 

  git push "https://user:$GITHUB_SSH@github.com/repo/mobile" --follow-tags
#fi

内容的提问来源于stack exchange,提问作者Dmytro Diachenko

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.09.24 13:36:04