-
Notifications
You must be signed in to change notification settings - Fork 38
36 lines (31 loc) · 1.16 KB
/
cleanup-pr-tarballs.yml
File metadata and controls
36 lines (31 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
name: Cleanup PR Tarballs
on:
schedule:
# Run daily at midnight UTC
- cron: '0 0 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
cleanup:
runs-on: ubuntu-latest
steps:
- name: Generate GitHub App Token
id: app-token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
- uses: actions/checkout@v6
- name: Delete PR tarball releases older than 7 days
env:
GH_TOKEN: ${{ steps.app-token.outputs.token }}
run: |
CUTOFF=$(date -u -d '7 days ago' +%Y-%m-%dT%H:%M:%SZ 2>/dev/null || date -u -v-7d +%Y-%m-%dT%H:%M:%SZ)
gh release list --limit 100 --json tagName,createdAt,isPrerelease \
--jq '.[] | select(.isPrerelease and (.tagName | startswith("pr-")) and (.tagName | endswith("-tarball")))' \
| jq -r --arg cutoff "$CUTOFF" 'select(.createdAt < $cutoff) | .tagName' \
| while read -r TAG; do
echo "Deleting old tarball release: $TAG"
gh release delete "$TAG" --yes --cleanup-tag 2>/dev/null || true
done