Conversation
…ance tagging strategy
Contributor
|
| # 获取分支名(去掉 refs/heads/ 前缀) | ||
| BRANCH_NAME="${GITHUB_REF#refs/heads/}" | ||
|
|
||
| # 处理分支名:转小写,替换 / 为 -,只保留字母数字和连字符 |
Contributor
There was a problem hiding this comment.
💡 建议添加边界情况处理
当前分支名处理逻辑缺少边界情况检查:
Suggested change
| # 处理分支名:转小写,替换 / 为 -,只保留字母数字和连字符 | |
| # 处理分支名:转小写,替换 / 为 -,只保留字母数字和连字符 | |
| SAFE_BRANCH_NAME=$(echo "$BRANCH_NAME" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9-]/-/g' | sed 's/--*/-/g' | sed 's/^-//;s/-$//') | |
| # 验证结果不为空 | |
| if [ -z "$SAFE_BRANCH_NAME" ]; then | |
| echo "Error: Invalid branch name after sanitization" | |
| exit 1 | |
| fi |
防止特殊分支名导致空 tag。
Comment on lines
86
to
+90
| echo "No changes to commit" | ||
| else | ||
| # 提交格式化后的代码 | ||
| git commit -m "chore: format code (dev-${{ steps.commit.outputs.short_sha }})" | ||
| git push origin dev | ||
| git commit -m "chore: format code (${{ steps.branch_info.outputs.versioned_tag }})" | ||
| git push origin ${{ steps.branch_info.outputs.branch_name }} |
Contributor
There was a problem hiding this comment.
🤔 潜在的自动提交问题
在所有非 main 分支都自动提交格式化修改,可能导致意外的 commit 历史污染。
建议:
- 仅在 dev 分支自动提交
- 其他分支只检查格式,不自动修复
Suggested change
| echo "No changes to commit" | |
| else | |
| # 提交格式化后的代码 | |
| git commit -m "chore: format code (dev-${{ steps.commit.outputs.short_sha }})" | |
| git push origin dev | |
| git commit -m "chore: format code (${{ steps.branch_info.outputs.versioned_tag }})" | |
| git push origin ${{ steps.branch_info.outputs.branch_name }} | |
| else | |
| # 仅在 dev 分支自动提交格式化 | |
| if [ "${{ steps.branch_info.outputs.branch_name }}" = "dev" ]; then | |
| git commit -m "chore: format code (${{ steps.branch_info.outputs.versioned_tag }})" | |
| git push origin ${{ steps.branch_info.outputs.branch_name }} | |
| else | |
| echo "::warning::Found formatting issues in non-dev branch. Please run 'pnpm format' locally." | |
| exit 1 | |
| fi |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dev分支扩展到所有非main分支主要变更
1. 触发条件优化
dev分支改为触发所有分支(排除main)2. 智能 Tag 生成
dev+dev-{sha}){branch-name}+{branch-name}-{sha}两个 tag/为-)3. Docker 镜像示例
Test plan
影响范围
.github/workflows/dev.yml🤖 Generated with Claude Code