forked from gridhead/gi-loadouts
-
Notifications
You must be signed in to change notification settings - Fork 0
28 lines (26 loc) · 982 Bytes
/
wipe.yml
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
---
name: Managing artifacts to retain four recent artifacts
on:
schedule:
- cron: 0 0 * * *
jobs:
ci-wipe:
runs-on: ubuntu-latest
steps:
- name: Manage artifacts to retain four recent artifacts
run: |
KEEP_QANT=4
ARTIFACT_UNIT=$(gh api repos/gridhead/gi-loadouts/actions/artifacts --paginate --jq '.artifacts | sort_by(.created_at) | .[].id')
ARTIFACT_LIST=($ARTIFACT_UNIT)
WIPE_QANT=$((${#ARTIFACT_LIST[@]} - $KEEP_QANT))
if [ $WIPE_QANT -gt 0 ]; then
for item in $(seq 0 $(($WIPE_QANT - 1))); do
ARTIFACT_ID=${ARTIFACT_LIST[$item]}
echo "Deleting artifact ID $ARTIFACT_ID..."
gh api repos/gridhead/gi-loadouts/actions/artifacts/$ARTIFACT_ID -X DELETE
done
else
echo "No artifacts available."
fi
env:
GITHUB_TOKEN: ${{ secrets.GHBTOKEN }}