Skip to content

Commit 775a45d

Browse files
committed
ci: delete testing fork pre-releases using upstream tag names
1 parent a1bcf9e commit 775a45d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,30 @@ 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:
1213
name: Delete pre-release if exists
14+
if: github.event.pull_request.merged == true
1315
runs-on: ubuntu-latest
1416
steps:
1517
- name: Delete pre-release and tag named after branch
1618
env:
1719
GH_TOKEN: ${{ github.token }}
1820
shell: bash
1921
run: |
22+
# Use either an upstream or fork PR branch
23+
if [[ "${{ github.event.pull_request.head.repo.full_name }}" != "${{ github.repository }}" ]]; then
24+
BRANCH="pull/${{ github.event.pull_request.number }}/head"
25+
else
26+
BRANCH="${{ github.event.pull_request.head.ref }}"
27+
fi
28+
2029
# Escape tags to create a semantic version
21-
REF=$(echo "${{ github.event.ref }}" | sed 's/\//-/g')
30+
REF=$(echo "${BRANCH}" | sed 's/\//-/g')
2231
RELEASE_FOUND=1
2332
2433
# Delete tags matching the pull request branch from forks

0 commit comments

Comments
 (0)