forked from Shelf-nu/shelf.nu
-
Notifications
You must be signed in to change notification settings - Fork 0
39 lines (33 loc) · 1.16 KB
/
ghcr_cleanup.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
29
30
31
32
33
34
35
36
37
38
39
# https://github.com/Koenkk/zigbee2mqtt/blob/fe0742a628fb782692f9679367e2ab1b11139dd6/.github/workflows/ghcr_cleanup.yml
name: 🧹 ghcr.io Cleanup
on:
workflow_dispatch:
permissions:
actions: write
contents: read
packages: write
env:
PACKAGE_NAME: shelf
PER_PAGE: 2000
jobs:
clean:
runs-on: ubuntu-latest
steps:
- name: 🗑 Delete untagged images
uses: actions/github-script@v7
with:
script: |
const response = await github.request("GET /user/packages/container/${{ env.PACKAGE_NAME }}/versions",
{ per_page: ${{ env.PER_PAGE }}
});
for(version of response.data) {
if (version.metadata.container.tags.length == 0) {
try {
console.log("delete " + version.id)
const deleteResponse = await github.request("DELETE /user/packages/container/${{ env.PACKAGE_NAME }}/versions/" + version.id, { });
console.log("status " + deleteResponse.status)
} catch (e) {
console.log("failed")
}
}
}