Skip to content

Commit e6d2d38

Browse files
committed
ci: optimize release cleanup
1 parent 760dbbe commit e6d2d38

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

.github/workflows/run.yml

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ on:
88
- master
99
paths-ignore:
1010
- "**/README.md"
11+
permissions:
12+
contents: write
1113
env:
1214
EXTRA_EXPORT_FILES: "netflix youtube primevideo hbo disney roku spotify tiktok twitch xvideos pornhub dmm dlsite telegram instagram threads facebook snap speedtest openai playstation nintendo xbox steam ea epicgames ubisoft"
1315

@@ -201,7 +203,7 @@ jobs:
201203
echo "NEED_RELEASE=true" >> $GITHUB_ENV
202204
elif ! diff -q rules.tar.sha256sum <(curl -sL "${{ env.RULETAR_HASH }}"); then
203205
echo "NEED_RELEASE=true" >> $GITHUB_ENV
204-
fi
206+
fi
205207
206208
- name: Git push assets to "release" branch
207209
if: ${{ env.NEED_RELEASE }}
@@ -216,6 +218,15 @@ jobs:
216218
git remote add origin "https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
217219
git push -f -u origin release
218220
221+
- name: Cleanup releases and tags
222+
env:
223+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
224+
KEEP_RELEASES: 5
225+
if: ${{ env.NEED_RELEASE }}
226+
run: |
227+
gh release list --repo "${{ github.repository }}" --limit 1000 --json tagName --jq ".[$KEEP_RELEASES:] | .[].tagName" | xargs -r -n1 gh release delete --repo "${{ github.repository }}" --cleanup-tag --yes
228+
shell: bash
229+
219230
- name: Release and upload assets
220231
if: ${{ env.NEED_RELEASE }}
221232
uses: svenstaro/upload-release-action@v2

0 commit comments

Comments
 (0)