You've already forked devops-pipeline-template
Refactor branch deletion script to improve clarity and maintainability
This commit is contained in:
@@ -21,10 +21,22 @@ jobs:
|
|||||||
- name: Delete merged branch
|
- name: Delete merged branch
|
||||||
run: |
|
run: |
|
||||||
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
|
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
|
||||||
echo "Deleting branch: $BRANCH_NAME"
|
echo "Branch name: $BRANCH_NAME"
|
||||||
|
|
||||||
#git config user.name "gitea-actions[bot]"
|
# Extract issue number from branch name (format: issue-122-issue-title)
|
||||||
#git config user.email "gitea-actions[bot]@gitea"
|
if [[ $BRANCH_NAME =~ ^issue-([0-9]+)- ]]; then
|
||||||
|
ISSUE_NUMBER="${BASH_REMATCH[1]}"
|
||||||
|
echo "Found issue number: $ISSUE_NUMBER"
|
||||||
|
|
||||||
#git push origin --delete "$BRANCH_NAME" || echo "Failed to delete branch $BRANCH_NAME"
|
if [ -n "$ISSUE_NUMBER" ]; then
|
||||||
#echo "Branch $BRANCH_NAME has been deleted"
|
git config user.name "gitea-actions[bot]"
|
||||||
|
git config user.email "gitea-actions[bot]@gitea"
|
||||||
|
|
||||||
|
git push origin --delete "$BRANCH_NAME" || echo "Failed to delete branch $BRANCH_NAME"
|
||||||
|
echo "Branch $BRANCH_NAME has been deleted"
|
||||||
|
|
||||||
|
fi
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Branch name does not match expected format (issue-NUMBER-title)"
|
||||||
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user