fix(ci): use gitea.ref instead of github.ref for tag detection #1639

Merged
xiaoxia merged 1 commits from fix/ci-gitea-ref-tag into develop 2026-09-03 12:50:33 +08:00
Owner

问题

Gitea Actions act runner v0.6.1 对 tag push 和 workflow_dispatch 事件不设置 github.ref 变量,导致 build-productiondeploy-productionproduction-e2e 三个 job 的 if 条件 startsWith(github.ref, 'refs/tags/v') 永远为 false,被 skip。

修复

将所有 startsWith(github.ref, ...) 替换为 startsWith(gitea.ref, ...)

gitea.ref 已在同一 workflow 的 concurrency group 中使用(ci-pipeline-${{ gitea.ref }}),确认可用。

影响范围

  • build-production: tag push 或 main 分支 push 时触发
  • deploy-production: tag push 时触发
  • production-e2e: tag push 时触发
## 问题 Gitea Actions act runner v0.6.1 对 tag push 和 workflow_dispatch 事件不设置 `github.ref` 变量,导致 `build-production`、`deploy-production`、`production-e2e` 三个 job 的 if 条件 `startsWith(github.ref, 'refs/tags/v')` 永远为 false,被 skip。 ## 修复 将所有 `startsWith(github.ref, ...)` 替换为 `startsWith(gitea.ref, ...)`。 `gitea.ref` 已在同一 workflow 的 concurrency group 中使用(`ci-pipeline-${{ gitea.ref }}`),确认可用。 ## 影响范围 - `build-production`: tag push 或 main 分支 push 时触发 - `deploy-production`: tag push 时触发 - `production-e2e`: tag push 时触发
xiaoxia added 1 commit 2026-09-03 12:43:03 +08:00
fix(ci): use gitea.ref instead of github.ref for tag detection in production jobs
CI/CD Pipeline / Check push changed paths (pull_request) Has been skipped
CI/CD Pipeline / Dedup Check - skip PR tests when covered by push pipeline (pull_request) Successful in 1s
CI/CD Pipeline / Check if frontend-only change (pull_request) Successful in 1s
CI/CD Pipeline / Frontend Lint (pull_request) Has been skipped
CI/CD Pipeline / Frontend Unit Tests (pull_request) Has been skipped
CI/CD Pipeline / PR Build Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging API Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Web Image (pull_request) Has been skipped
CI/CD Pipeline / Retag skipped Staging Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Staging (Watchtower auto-deploy) (pull_request) Has been skipped
CI/CD Pipeline / Staging E2E Tests (pull_request) Has been skipped
CI/CD Pipeline / Staging API Integration Tests (pull_request) Has been skipped
CI/CD Pipeline / ACR Image Cleanup (pull_request) Has been skipped
PR Automation / Auto Merge on CI Green + Approved (pull_request) Successful in 1m10s
Preview Deploy / Deploy Preview Environment (pull_request) Successful in 1m23s
CI/CD Pipeline / Validate - Python (mypy + alembic) (pull_request) Successful in 1m54s
CI/CD Pipeline / Integration Tests (pull_request) Successful in 1m55s
CI/CD Pipeline / PR Build Worker Image (pull_request) Successful in 2m5s
CI/CD Pipeline / PR Build API Image (pull_request) Successful in 2m7s
CI/CD Pipeline / Validate - Style (pull_request) Successful in 2m15s
PR Automation / Auto Approve on CI Green (pull_request) Successful in 2m50s
AI Code Review / AI Code Review (pull_request) Failing after 2m53s
CI/CD Pipeline / Validate - Security (pull_request) Successful in 4m40s
CI/CD Pipeline / Unit Tests (pull_request) Successful in 6m44s
CI/CD Pipeline / Build Production API Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Web Image (pull_request) Has been skipped
CI/CD Pipeline / Build Production Worker Image (pull_request) Has been skipped
CI/CD Pipeline / Deploy Production (pull_request) Has been skipped
CI/CD Pipeline / Canary Release to Production (pull_request) Has been skipped
CI/CD Pipeline / Production Browser E2E (pull_request) Has been skipped
CI/CD Pipeline / CI Gate (pull_request) Successful in 2s
ACR Cleanup / ACR Image Cleanup (pull_request_target) Successful in 8s
Preview Cleanup / Cleanup Preview Environment (pull_request) Successful in 16s
5253f2eeb9

🚀 预览环境已部署

项目 详情
PR号 #1639
预览链接 https://pr-1639.preview.xiaoxiajianji.com
API环境 staging

💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。

🔄 每次提交新代码后预览环境会自动更新。

🗑️ PR 关闭或合并后,预览环境会自动清理。

🚀 **预览环境已部署** | 项目 | 详情 | |------|------| | PR号 | #1639 | | 预览链接 | [https://pr-1639.preview.xiaoxiajianji.com](https://pr-1639.preview.xiaoxiajianji.com) | | API环境 | staging | > 💡 预览环境使用 staging API 数据,请勿在预览环境中操作重要数据。 > > 🔄 每次提交新代码后预览环境会自动更新。 > > 🗑️ PR 关闭或合并后,预览环境会自动清理。
Collaborator

【阻塞级判定】

  • 是否存在阻塞级问题:是
  • 阻塞级问题数量:1 个

📊 审查概览

  • 整体评价:需修改
  • 建议级问题数量:0 个

🔴 阻塞级问题(必须修复)

  1. [.gitea/workflows/ci-pipeline.yml:1465] 上下文变量混用导致逻辑风险
    • 问题类型:逻辑bug
    • 问题描述:该行代码将条件判断的前半部分从 github.ref 修改为 gitea.ref,但后半部分仍保留了 github.event_namegithub.ref_name。虽然 Gitea Actions 通常模拟 GitHub 上下文,但在同一个逻辑表达式中混用 giteagithub 命名空间是不一致且危险的。如果 Gitea 实例的 github 上下文模拟不完整或在未来版本中被移除,会导致该条件判断失效,进而影响生产环境的构建或部署触发逻辑。
    • 修改建议:统一使用 gitea 命名空间,确保逻辑一致性。修改为:
      if: startsWith(gitea.ref, 'refs/tags/v') || (gitea.event_name == 'push' && gitea.ref_name == 'main')

💡 改进建议(不阻塞合并)

良好实践

  • deploy-productionProduction Browser E2E 任务中正确地将 github.ref 替换为 gitea.ref,符合 Gitea Actions 的原生用法。

🤖 由 AI 代码审查机器人自动生成 | 2026-09-03 04:45:56 | 模型:

### 【阻塞级判定】 - 是否存在阻塞级问题:是 - 阻塞级问题数量:1 个 ### 📊 审查概览 - 整体评价:需修改 - 建议级问题数量:0 个 ### 🔴 阻塞级问题(必须修复) 1. **[.gitea/workflows/ci-pipeline.yml:1465] 上下文变量混用导致逻辑风险** - 问题类型:逻辑bug - 问题描述:该行代码将条件判断的前半部分从 `github.ref` 修改为 `gitea.ref`,但后半部分仍保留了 `github.event_name` 和 `github.ref_name`。虽然 Gitea Actions 通常模拟 GitHub 上下文,但在同一个逻辑表达式中混用 `gitea` 和 `github` 命名空间是不一致且危险的。如果 Gitea 实例的 `github` 上下文模拟不完整或在未来版本中被移除,会导致该条件判断失效,进而影响生产环境的构建或部署触发逻辑。 - 修改建议:统一使用 `gitea` 命名空间,确保逻辑一致性。修改为: `if: startsWith(gitea.ref, 'refs/tags/v') || (gitea.event_name == 'push' && gitea.ref_name == 'main')` ### 💡 改进建议(不阻塞合并) 无 ### ✅ 良好实践 - 在 `deploy-production` 和 `Production Browser E2E` 任务中正确地将 `github.ref` 替换为 `gitea.ref`,符合 Gitea Actions 的原生用法。 --- <sub>🤖 由 AI 代码审查机器人自动生成 | 2026-09-03 04:45:56 | 模型: </sub> <!-- AI_CODE_REVIEW_AUTO_COMMENT -->
xiaoxia merged commit 7c5ab078bb into develop 2026-09-03 12:50:33 +08:00
xiaoxia deleted branch fix/ci-gitea-ref-tag 2026-09-03 12:50:33 +08:00

🗑️ 预览环境已清理

PR #1639 已关闭或合并,对应的预览环境已被清理。

如有需要,可以重新打开 PR 来重新生成预览环境。

🗑️ **预览环境已清理** PR #1639 已关闭或合并,对应的预览环境已被清理。 > 如有需要,可以重新打开 PR 来重新生成预览环境。
Sign in to join this conversation.