File tree Expand file tree Collapse file tree 1 file changed +2
-17
lines changed Expand file tree Collapse file tree 1 file changed +2
-17
lines changed Original file line number Diff line number Diff line change @@ -58,29 +58,14 @@ jobs:
5858 - name : Check if target_sync_branch exists in the remote
5959 id : check-branch-exists
6060 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."
7661 # 创建一个临时分支来fetch远程分支的内容
7762 git fetch upstream ${{ inputs.upstream_sync_branch }}:temp_${{ inputs.upstream_sync_branch }}
7863 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
8066 git branch ${{ inputs.target_sync_branch }} temp_${{ inputs.upstream_sync_branch }} # 创建新分支
8167 # 强制推送新分支到远程仓库
8268 git push --force origin ${{ inputs.target_sync_branch }}
83- fi
8469
8570 # # REQUIRED step
8671 # # Step 2: run the sync action
You can’t perform that action at this time.
0 commit comments