-
-
Notifications
You must be signed in to change notification settings - Fork 110
49 lines (42 loc) · 1.38 KB
/
Copy pathcleanup.yml
File metadata and controls
49 lines (42 loc) · 1.38 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
37
38
39
40
41
42
43
44
45
46
47
48
49
name: cleanup
on:
schedule:
- cron: '0 6 * * 1' # Mondays 06:00 UTC (offset by +1h from firmware's cleanup)
workflow_dispatch:
permissions:
contents: write
actions: write
concurrency:
group: gh-pages-manifest
cancel-in-progress: false
jobs:
prune:
name: Prune old nightly releases
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Delete releases beyond the 90 newest
id: prune
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
to_delete=$(gh release list --limit 200 --json tagName,createdAt \
| jq -r '[ .[] | select(.tagName | test("^nightly-[0-9]{8}-[0-9a-f]{7}$")) ]
| sort_by(.createdAt) | reverse | .[90:] | .[].tagName')
if [ -z "$to_delete" ]; then
echo "Nothing to delete; <=90 dated nightlies present."
echo "pruned=false" >> "$GITHUB_OUTPUT"
exit 0
fi
echo "$to_delete" | while read -r tag; do
[ -z "$tag" ] && continue
echo "Deleting $tag"
gh release delete "$tag" --cleanup-tag --yes
done
echo "pruned=true" >> "$GITHUB_OUTPUT"
- name: Refresh manifest
if: steps.prune.outputs.pruned == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh workflow run manifest.yml