-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
466483b
commit cba5b9c
Showing
5 changed files
with
89 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,18 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
# Delete snapshots from closed PRs. | ||
PRNUMS=$(hub pr list -s closed --format='%I ' --limit=10 --sort=updated) | ||
limit=100 | ||
closed_prs=$(gh pr list --state closed --json number --jq '.[].number' --limit $limit) | ||
pr_release_tags=$(gh release list --limit $limit | grep -E "PR[0-9]+-SNAPSHOT" | awk '{print $3}') | ||
|
||
for N in $PRNUMS; | ||
# Loop over the closed PRs and delete any releases that correspond to a closed PR. | ||
for pr in $closed_prs | ||
do | ||
TAGS=$(hub release | grep "PR$N-" || true) | ||
for T in $TAGS; | ||
echo "Checking PR $pr" | ||
for tag in $(echo "$pr_release_tags" | grep "PR$pr-SNAPSHOT") | ||
do | ||
echo "Deleting $T" | ||
gh release delete "$T" --yes | ||
git push --delete origin "$T" | ||
echo "Deleting release $tag" | ||
gh release delete "$tag" --yes | ||
git push --delete origin "$tag" | ||
done | ||
done | ||
|
||
# Delete snapshots from master. | ||
TAGS=$(hub release | grep "MAIN[0-9]*-SNAPSHOT" || true) | ||
for T in $TAGS; | ||
do | ||
gh release delete "$T" --yes | ||
git push --delete origin "$T" | ||
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: "Cleanup Snapshots" | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
workflow_dispatch: | ||
|
||
jobs: | ||
cleanup-snapshots: | ||
name: Cleanup Snapshots | ||
runs-on: | ||
- ubuntu-22.04 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- run: ./.github/scripts/delete-snapshot-releases.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.