-
Notifications
You must be signed in to change notification settings - Fork 0
35 lines (33 loc) · 1.34 KB
/
remove-untagged.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
name: Remove untagged images
on:
workflow_dispatch:
# schedule:
# - cron: "0 4 * * *" # Every day at 04:00
jobs:
remove-untagged:
runs-on: ubuntu-latest
strategy:
matrix:
image-name: [tna-python, tna-python-root, tna-python-django, tna-python-django-root, tna-python-dev]
env:
PER_PAGE: 100
steps:
- name: Remove untagged images
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const response = await github.request("GET /orgs/${{ github.repository_owner }}/packages/container/${{ matrix.image-name }}/versions",
{ per_page: ${{ env.PER_PAGE }}
});
for(version of response.data) {
console.log("=====================")
console.log(version)
if (version.metadata.container.tags.length) {
console.log(`Tags: ${version.metadata.container.tags.join(", ")}`)
} else {
console.log(`Delete ${version.id} (${version.name})`)
const deleteResponse = await github.request("DELETE /orgs/${{ github.repository_owner }}/packages/container/${{ matrix.image-name }}/versions/" + version.id, { });
console.log(deleteResponse.status)
}
}