Skip to content

T0000: 12

T0000: 12 #7

name: Cleanup pr mirror branch
on:
pull_request:
types: [closed]
branches:
- current
workflow_dispatch:
inputs:
branch:
description: 'Branch to delete'
required: true
permissions:
contents: write
jobs:
delete_branch:
if: ${{ (github.event_name == 'workflow_dispatch' || startsWith(github.event.pull_request.head.ref, 'mirror/current/')) && github.repository_owner != 'vyos' }}
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Delete branch
run: |
branch=${{ github.event_name == 'workflow_dispatch' && github.event.inputs.branch || github.event.pull_request.head.ref }}
if [[ $branch != mirror/current/* ]]; then
echo "Branch name to clean must start with 'mirror/current/'"
exit 1
fi
repo=${{ github.repository }}
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}
git push origin --delete $branch