File tree Expand file tree Collapse file tree 1 file changed +12
-3
lines changed
Expand file tree Collapse file tree 1 file changed +12
-3
lines changed Original file line number Diff line number Diff 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.
66on :
7- delete :
8- branches :
7+ pull_request :
8+ types :
9+ - closed
910
1011jobs :
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
You can’t perform that action at this time.
0 commit comments