From 6bd192b99a050988a769efa6b499e79da6b8f2d3 Mon Sep 17 00:00:00 2001 From: Coldwings Date: Fri, 13 Dec 2024 14:33:41 +0800 Subject: [PATCH] auto delete auto-pr branch which is merged --- .github/workflows/auto-pr-autodelete.yml | 26 ++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/auto-pr-autodelete.yml diff --git a/.github/workflows/auto-pr-autodelete.yml b/.github/workflows/auto-pr-autodelete.yml new file mode 100644 index 00000000..8ea28010 --- /dev/null +++ b/.github/workflows/auto-pr-autodelete.yml @@ -0,0 +1,26 @@ +name: Auto PR Branch Cleanup + +on: + pull_request: + types: + - closed + +jobs: + clean-auto-pr: + if: ${{ github.event.pull_request.merged }} && + ${{ github.event.pull_request.head.repo.id == github.event.pull_request.base.repo.id }} && + ${{ github.event.pull_request.head.ref == 'auto-pr-*' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: set git config + run: | + git config --global user.email "${GITHUB_ACTOR_ID}+${GITHUB_ACTOR}@users.noreply.github.com" + git config --global user.name "${GITHUB_ACTOR}" + git config --global advice.mergeConflict false + git config --global --add safe.directory "${{ github.workspace }}" + git config -l + git push -d origin ${{ github.event.pull_request.head.ref }} \ No newline at end of file