Skip to content

Commit 616126f

Browse files
authored
feat: implement better clean up strategy (#926)
* feat: use different action to clean up PR images * feat: add cron based clean-up of orphaned images * chore: fix packages format * chore: add amp-devcontainer image to clean-up * chore: remove dry-run * chore: delete untagged images * chore: remove dry-run * chore: remove test code and prepare for merge
1 parent deb97bf commit 616126f

File tree

2 files changed

+33
-16
lines changed

2 files changed

+33
-16
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
---
2+
name: Cleanup Images
3+
4+
on:
5+
schedule:
6+
- cron: "0 0 * * 3"
7+
workflow_dispatch:
8+
9+
permissions: {}
10+
11+
jobs:
12+
delete-images:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
# dataaxiom/ghcr-cleanup-action needs packages write permission
16+
# to delete untagged and orphaned images
17+
packages: write
18+
steps:
19+
- uses: step-security/harden-runner@ec9f2d5744a09debf3a187a3f4f675c53b671911 # v2.13.0
20+
with:
21+
disable-sudo: true
22+
egress-policy: block
23+
allowed-endpoints: >
24+
api.github.com:443
25+
ghcr.io:443
26+
- uses: dataaxiom/ghcr-cleanup-action@cd0cdb900b5dbf3a6f2cc869f0dbb0b8211f50c4 # v1.0.16
27+
with:
28+
delete-orphaned-images: true
29+
delete-untagged: true
30+
packages: amp-devcontainer,amp-devcontainer-cpp,amp-devcontainer-rust

.github/workflows/pr-image-cleanup.yml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,33 +7,20 @@ on:
77

88
permissions: {}
99

10-
env:
11-
REGISTRY: ghcr.io
12-
1310
jobs:
1411
delete-images:
1512
runs-on: ubuntu-latest
16-
strategy:
17-
matrix:
18-
flavor: ["cpp", "rust"]
1913
permissions:
2014
packages: write
2115
steps:
2216
- uses: step-security/harden-runner@f4a75cfd619ee5ce8d5b864b0d183aff3c69b55a # v2.13.1
2317
with:
2418
disable-sudo: true
2519
egress-policy: audit
26-
- uses: docker/login-action@184bdaa0721073962dff0199f1fb9940f07167d1 # v3.5.0
27-
with:
28-
registry: ${{ env.REGISTRY }}
29-
username: ${{ github.actor }}
30-
password: ${{ secrets.GITHUB_TOKEN }}
31-
- uses: bots-house/ghcr-delete-image-action@3827559c68cb4dcdf54d813ea9853be6d468d3a4 # v1.1.0
20+
- uses: dataaxiom/ghcr-cleanup-action@cd0cdb900b5dbf3a6f2cc869f0dbb0b8211f50c4 # v1.0.16
3221
with:
33-
owner: ${{ github.repository_owner }}
34-
name: ${{ github.event.repository.name }}-${{ matrix.flavor }}
35-
token: ${{ secrets.GITHUB_TOKEN }}
36-
tag: pr-${{ github.event.pull_request.number }}
22+
delete-tags: pr-${{ github.event.pull_request.number }}
23+
packages: amp-devcontainer,amp-devcontainer-cpp,amp-devcontainer-rust
3724
cleanup-cache:
3825
runs-on: ubuntu-latest
3926
permissions:

0 commit comments

Comments
 (0)