File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ name : Delete generated output branch after merge
2+
3+ on :
4+ pull_request :
5+ types : [closed]
6+
7+ permissions :
8+ contents : write
9+
10+ jobs :
11+ cleanup-output-branch :
12+ if : github.event.pull_request.merged == true && github.event.pull_request.head.repo.full_name == github.repository
13+ runs-on : ubuntu-latest
14+
15+ steps :
16+ - name : Delete Bauer parse-output branch after merge
17+ env :
18+ PR_BODY : ${{ github.event.pull_request.body }}
19+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
20+ run : |
21+ # Detect the Bauer parse-output branch referenced in the PR body,
22+ # e.g. "bauer/doc-suggestions-<id>".
23+ BAUER_BRANCH=$(printf '%s' "$PR_BODY" \
24+ | grep -oE 'bauer/doc-suggestions-[A-Za-z0-9._-]+' \
25+ | head -n 1)
26+
27+ if [ -z "$BAUER_BRANCH" ]; then
28+ echo "No Bauer parse-output branch found in PR body, nothing to do."
29+ exit 0
30+ fi
31+
32+ echo "Deleting branch: $BAUER_BRANCH"
33+ gh api \
34+ -X DELETE \
35+ "repos/${{ github.repository }}/git/refs/heads/$BAUER_BRANCH"
You can’t perform that action at this time.
0 commit comments