-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #22 from litetex/delete-old-releases
Create workflow to delete old releases
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: Delete old releases | ||
|
||
on: | ||
schedule: | ||
- cron: '15 23 * * *' | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: write | ||
|
||
jobs: | ||
cleanup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
# Related: https://github.com/actions/checkout/issues/1471 | ||
- name: Fetch tags | ||
run: git fetch --prune --unshallow --tags | ||
|
||
- name: Delete old releases if required | ||
run: | | ||
# Keep last 50 releases | ||
tags_to_delete=($(git tag --sort=-v:refname | grep nightly- | tail -n+50)) | ||
if (( ${#tags_to_delete[@]} )); then | ||
echo "Will delete ${tags_to_delete[*]}" | ||
for tag_to_delete in "${tags_to_delete[@]}" | ||
do | ||
echo "Deleting $tag_to_delete" | ||
git push -v --delete origin "$tag_to_delete" | ||
# Delete GitHub release if present | ||
gh release delete -y "$tag_to_delete" || true | ||
done | ||
fi | ||
env: | ||
GH_TOKEN: ${{ github.token }} |