Skip to content

Commit b939841

Browse files
authored
ci: delete pre-releases matching existing or escaped tags (#40)
1 parent fdab4c7 commit b939841

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

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

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,22 @@ jobs:
1717
GH_TOKEN: ${{ github.token }}
1818
shell: bash
1919
run: |
20+
# Escape tags to create a semantic version
21+
REF=$(echo "${{ github.event.ref }}" | sed 's/\//-/g')
22+
RELEASE_FOUND=1
23+
24+
# Delete tags matching the pull request branch from forks
25+
if GH_DEBUG=1 gh release --repo="slackapi/slack-cli" delete "${REF}" -y --cleanup-tag; then
26+
echo "Successfully deleted ${REF}"
27+
RELEASE_FOUND=0
28+
else
29+
echo "Did not find ${REF} tag, trying version prefixes..."
30+
fi
31+
2032
# Figure out tag name from branch name. This is coupled to the tag name generation that exists in .circleci/config.yml's `create-github-release` job.
2133
RELEASES=$(gh release list --repo="slackapi/slack-cli" --order="desc" --json="tagName" --exclude-drafts --exclude-pre-releases --limit=24 --jq ".[] | .tagName")
22-
RELEASE_FOUND=1
2334
for TAGS in $RELEASES; do
24-
TAG_NAME="${TAGS}-${{ github.event.ref }}"
35+
TAG_NAME="${TAGS}-${REF}"
2536
echo "Identified pre-release tagname to 🔪: $TAG_NAME"
2637
2738
# Delete the pre-release

0 commit comments

Comments
 (0)