Skip to content

Commit 584a055

Browse files
zimegmwbrooks
andauthored
ci(fix): delete branch prereleases started in prior versions on merge to main (#15)
Co-authored-by: Michael Brooks <mbrooks@slack-corp.com>
1 parent 1482e2e commit 584a055

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

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

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,18 @@ jobs:
1818
shell: bash
1919
run: |
2020
# 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.
21-
LATEST_RELEASE_TAG=$(gh release list --repo slackapi/slack-cli --json tagName,isLatest --jq ".[] | select(.isLatest == true) | .tagName" )
22-
TAG_NAME="$LATEST_RELEASE_TAG-${{ github.event.ref }}"
23-
echo "Identified pre-release tagname to 🔪: $TAG_NAME"
24-
# Delete the pre-release
25-
GH_DEBUG=1 gh release --repo slackapi/slack-cli delete $TAG_NAME -y --cleanup-tag
21+
RELEASES=$(gh release list --repo="slackapi/slack-cli" --order="desc" --json="tagName" --exclude-drafts --exclude-pre-releases --limit=24 --jq ".[] | .tagName")
22+
for TAGS in $RELEASES; do
23+
TAG_NAME="${TAGS}-${{ github.event.ref }}"
24+
echo "Identified pre-release tagname to 🔪: $TAG_NAME"
25+
26+
# Delete the pre-release
27+
if GH_DEBUG=1 gh release --repo="slackapi/slack-cli" delete "$TAG_NAME" -y --cleanup-tag; then
28+
echo "Successfully deleted $TAG_NAME"
29+
exit 0
30+
else
31+
echo "Failed to find $TAG_NAME, trying next..."
32+
fi
33+
done
34+
echo "No matching pre-releases tag was found for the branch $TAG_NAME in recent versions"
35+
exit 1

0 commit comments

Comments
 (0)