Skip to content

Commit 1e29f5a

Browse files
authored
Refactor branch creation in CodeQL workflow
Update branch creation logic to handle existing branches gracefully.
1 parent 45f386e commit 1e29f5a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎.github/workflows/codeql-to-commit.yml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ jobs:
2222
OWNER: ${{ github.repository_owner }}
2323
REPO: ${{ github.event.repository.name }}
2424
run: |
25+
set +e
2526
DEFAULT_BRANCH=$(gh api /repos/$OWNER/$REPO --jq '.default_branch')
2627
echo "Default branch: $DEFAULT_BRANCH"
2728
@@ -91,9 +92,8 @@ jobs:
9192
# 创建分支
9293
gh api -X POST /repos/$OWNER/$REPO/git/refs \
9394
-f ref="refs/heads/$BRANCH" \
94-
-f sha="$SHA" 2>/dev/null && \
95-
echo "🌿 Created branch: $BRANCH" || \
96-
echo "🌿 Branch already exists: $BRANCH"
95+
-f sha="$SHA" 2>/dev/null || true
96+
echo "🌿 Branch created or already exists: $BRANCH"
9797
9898
# 提交 fix
9999
COMMIT_RESULT=$(gh api -X POST \
@@ -179,4 +179,4 @@ jobs:
179179
echo "⚠️ Autofix not available for alert #$NUMBER (status: $EXISTING), skipping"
180180
fi
181181
182-
done
182+
done

0 commit comments

Comments
 (0)