File tree 1 file changed +2
-17
lines changed
1 file changed +2
-17
lines changed Original file line number Diff line number Diff line change @@ -58,29 +58,14 @@ jobs:
58
58
- name : Check if target_sync_branch exists in the remote
59
59
id : check-branch-exists
60
60
run : |
61
- # Use GitHub API to get the branch information
62
- RESPONSE=$(curl -s -H "Authorization: token${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/${{ inputs.target_sync_repo }}/branches/${{ inputs.target_sync_branch }}")
63
- # Check if the response contains 'Not Found' which indicates the branch does not exist
64
- if echo "$RESPONSE" | grep -q "Not Found"; then
65
- echo "branch_exists=false" >> $GITHUB_OUTPUT
66
- echo "Remote branch ${{ inputs.target_sync_branch }} does not exist."
67
- # 创建一个临时分支来fetch远程分支的内容
68
- git fetch upstream ${{ inputs.upstream_sync_branch }}:temp_${{ inputs.upstream_sync_branch }}
69
- # 基于临时分支创建新的本地分支
70
- git checkout -b ${{ inputs.target_sync_branch }} temp_${{ inputs.upstream_sync_branch }}
71
- # 推送新分支到远程仓库
72
- git push origin ${{ inputs.target_sync_branch }}
73
- else
74
- echo "branch_exists=true" >> $GITHUB_OUTPUT
75
- echo "Remote branch ${{ inputs.target_sync_branch }} exists."
76
61
# 创建一个临时分支来fetch远程分支的内容
77
62
git fetch upstream ${{ inputs.upstream_sync_branch }}:temp_${{ inputs.upstream_sync_branch }}
78
63
git checkout temp_${{ inputs.upstream_sync_branch }}
79
- git branch -D ${{ inputs.target_sync_branch }} # 强制删除本地分支
64
+ # 强制删除本地分支 并忽略报错(如果分支不存在)
65
+ git branch -D ${{ inputs.target_sync_branch }} || true
80
66
git branch ${{ inputs.target_sync_branch }} temp_${{ inputs.upstream_sync_branch }} # 创建新分支
81
67
# 强制推送新分支到远程仓库
82
68
git push --force origin ${{ inputs.target_sync_branch }}
83
- fi
84
69
85
70
# # REQUIRED step
86
71
# # Step 2: run the sync action
You can’t perform that action at this time.
0 commit comments