Skip to content

Perform branch cleanup from APG trigger #210

Perform branch cleanup from APG trigger

Perform branch cleanup from APG trigger #210

Workflow file for this run

name: Perform branch cleanup from APG trigger
on:
workflow_dispatch:
inputs:
apg_branch:
description: 'Name of branch to be removed'
required: true
jobs:
remove-branch:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check if branch exists
id: check_if_exists
run: |
BRANCH_EXISTS=$(git ls-remote --heads https://github.com/${{ github.repository_owner }}/wai-aria-practices.git apg/${{ github.event.inputs.apg_branch }} | wc -l)
echo "BRANCH_EXISTS=$BRANCH_EXISTS" >> "$GITHUB_OUTPUT"
- name: Clean up generated branch
if: ${{ steps.check_if_exists.outputs.BRANCH_EXISTS == '1' }}
run: |
BRANCH_NAME="apg/${{ github.event.inputs.apg_branch }}"
git config --global user.name "w3cgruntbot"
git config --global user.email "[email protected]"
git push origin --delete $BRANCH_NAME
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Report branch already removed
if: ${{ steps.check_if_exists.outputs.BRANCH_EXISTS == '0' }}
run: echo "Branch already removed"