fix(ci): use github.ref_name for tag detection (gitea.ref not available in runner) #1640
Reference in New Issue
Block a user
Delete Branch "fix/ci-ref-name-tag-detection"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题
PR #1639 将
github.ref改为gitea.ref,但 runner 日志显示gitea.ref同样为空,Build Production 仍然被 skip。Runner 日志:
根因
Gitea Actions act runner v0.6.1 对 tag push 事件不设置
github.ref也不设置gitea.ref,但github.ref_name是可用的(在 runner 日志中可见其被正确引用)。修复
将
startsWith(gitea.ref, refs/tags/v)改为startsWith(github.ref_name, v)。tag push 时
github.ref_name=v0.1.135(不含refs/tags/前缀),所以用startsWith(..., v)即可匹配。【阻塞级判定】
📊 审查概览
🔴 阻塞级问题(必须修复)
startsWith(gitea.ref, 'refs/tags/v')明确限定了引用必须以refs/tags/v开头,即只匹配以v开头的 Tag。修改后使用github.ref_name(短引用名)并仅判断是否以v开头,丢失了对引用类型的校验。这会导致名为verify-fix、version-update等以v开头的分支也会触发生产构建和部署,造成严重的误操作和资源浪费。startsWith(github.ref, 'refs/tags/v')(使用完整引用),或修改为(startsWith(github.ref_name, 'v') && github.ref_type == 'tag')。💡 改进建议(不阻塞合并)
.gitea/workflows目录下,但代码中混用了gitea(如concurrency.group中)和github(如if条件中)上下文变量。虽然 Gitea Actions 兼容 GitHub 语法,但建议统一使用gitea上下文变量(如gitea.ref_name,gitea.event_name)以确保在 Gitea 环境下的最佳兼容性和明确性,除非该工作流需要同时在 GitHub 上运行。✅ 良好实践
无
🤖 由 AI 代码审查机器人自动生成 | 2026-09-03 05:12:55 | 模型:
🚀 预览环境已部署
🗑️ 预览环境已清理
PR #1640 已关闭或合并,对应的预览环境已被清理。