You've already forked devops-pipeline-template
Add workflows for closing and deleting branches on PR merge
This commit is contained in:
30
.gitea/workflows/pr-delete-branch.yml
Normal file
30
.gitea/workflows/pr-delete-branch.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
name: PR Delete Branch (Template)
|
||||
|
||||
on:
|
||||
workflow_call:
|
||||
secrets:
|
||||
GITHUB_TOKEN:
|
||||
required: true
|
||||
|
||||
jobs:
|
||||
delete-branch:
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.pull_request.merged == true
|
||||
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
- name: Delete merged branch
|
||||
run: |
|
||||
BRANCH_NAME="${{ github.event.pull_request.head.ref }}"
|
||||
echo "Deleting branch: $BRANCH_NAME"
|
||||
|
||||
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"
|
||||
Reference in New Issue
Block a user