Skip to content

Commit e34e518

Browse files
authored
ci: delete testing fork pre-releases using upstream tag names (#48)
1 parent a1bcf9e commit e34e518

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

.github/workflows/delete-pr-build-on-close.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,9 @@ name: Delete pre-release when a branch is deleted
44
# The circleci config builds CLI binaries when a PR is opened and hosts them under a GitHub (pre-)release named after the PR branch
55
# This workflow action deletes that pre-release when a PR is merged or closed.
66
on:
7-
delete:
8-
branches:
7+
pull_request:
8+
types:
9+
- closed
910

1011
jobs:
1112
delete-pre-release:
@@ -17,8 +18,15 @@ jobs:
1718
GH_TOKEN: ${{ github.token }}
1819
shell: bash
1920
run: |
21+
# Use either an upstream or fork PR branch
22+
if [[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
23+
BRANCH="pull/${{ github.event.pull_request.number }}/head"
24+
else
25+
BRANCH="${{ github.event.pull_request.head.ref }}"
26+
fi
27+
2028
# Escape tags to create a semantic version
21-
REF=$(echo "${{ github.event.ref }}" | sed 's/\//-/g')
29+
REF=$(echo "${BRANCH}" | sed 's/\//-/g')
2230
RELEASE_FOUND=1
2331
2432
# Delete tags matching the pull request branch from forks

0 commit comments

Comments
 (0)