From f40a7b013bd7a56ee38d35406844a0916b876b56 Mon Sep 17 00:00:00 2001 From: Vedran Kasalica Date: Mon, 2 Sep 2024 23:43:00 +0200 Subject: [PATCH 1/8] Update clean-containers --- .github/workflows/clean-containers.yaml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/clean-containers.yaml b/.github/workflows/clean-containers.yaml index b4ab0a0..af6684b 100644 --- a/.github/workflows/clean-containers.yaml +++ b/.github/workflows/clean-containers.yaml @@ -1,9 +1,9 @@ name: "Clean the old docker images" on: - workflow_dispatch: # This line adds the manual trigger + workflow_dispatch: # Manual trigger schedule: - - cron: "21 21 * * *" + - cron: "21 21 * * *" # Scheduled run jobs: clean-ghcr: @@ -13,19 +13,19 @@ jobs: packages: write env: REGISTRY: ghcr.io + steps: - - name: downcase REPO name - run: | - echo "REPO=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV + - name: Set REPO environment variable + run: echo "REPO=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV + - name: Delete 'PR' containers older than a week uses: snok/container-retention-policy@v3.0.0 with: + account: user image-names: ${{ env.REGISTRY }}/${{ env.REPO }} - filter-tags: "sha-*,sha256:*" - skip-tags: latest - cut-off: "A week ago UTC" - account-type: org - org-name: ${{ github.repository_owner }} - keep-at-least: 1 token: ${{ secrets.GH_REPO_TOKEN }} - timestamp-to-use: updated_at + image-tags: "pr*" # target any image that has a tag starting with the word test or dev + # image-tags: "!latest" + cut-off: 2w 3d + dry-run: true + From c20030e081abee021654f4980c2cfd2150c3399f Mon Sep 17 00:00:00 2001 From: Vedran Kasalica Date: Mon, 2 Sep 2024 23:46:29 +0200 Subject: [PATCH 2/8] Update cleaning image-tags --- .github/workflows/clean-containers.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/clean-containers.yaml b/.github/workflows/clean-containers.yaml index af6684b..2c63f23 100644 --- a/.github/workflows/clean-containers.yaml +++ b/.github/workflows/clean-containers.yaml @@ -1,6 +1,9 @@ name: "Clean the old docker images" on: + push: + branches: + - main workflow_dispatch: # Manual trigger schedule: - cron: "21 21 * * *" # Scheduled run From 80a4ab110e13140d4618ea91b4f2718a20b6e0a9 Mon Sep 17 00:00:00 2001 From: Vedran Kasalica Date: Mon, 2 Sep 2024 23:53:28 +0200 Subject: [PATCH 3/8] Try no restriction on name --- .github/workflows/clean-containers.yaml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/clean-containers.yaml b/.github/workflows/clean-containers.yaml index 2c63f23..e310631 100644 --- a/.github/workflows/clean-containers.yaml +++ b/.github/workflows/clean-containers.yaml @@ -1,9 +1,6 @@ name: "Clean the old docker images" on: - push: - branches: - - main workflow_dispatch: # Manual trigger schedule: - cron: "21 21 * * *" # Scheduled run @@ -25,10 +22,9 @@ jobs: uses: snok/container-retention-policy@v3.0.0 with: account: user - image-names: ${{ env.REGISTRY }}/${{ env.REPO }} + image-names: "!latest" token: ${{ secrets.GH_REPO_TOKEN }} - image-tags: "pr*" # target any image that has a tag starting with the word test or dev - # image-tags: "!latest" + image-tags: "!latest" cut-off: 2w 3d dry-run: true From 9a009e2beadfdd7495e70de22ab53987aadbba23 Mon Sep 17 00:00:00 2001 From: Vedran Kasalica Date: Tue, 3 Sep 2024 00:03:03 +0200 Subject: [PATCH 4/8] Update the gh clean action --- .github/workflows/clean-containers.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/clean-containers.yaml b/.github/workflows/clean-containers.yaml index e310631..ccf504f 100644 --- a/.github/workflows/clean-containers.yaml +++ b/.github/workflows/clean-containers.yaml @@ -21,10 +21,10 @@ jobs: - name: Delete 'PR' containers older than a week uses: snok/container-retention-policy@v3.0.0 with: - account: user + account: sanctuuary image-names: "!latest" token: ${{ secrets.GH_REPO_TOKEN }} - image-tags: "!latest" cut-off: 2w 3d dry-run: true + keep-n-most-recent: 1 From e055cec09e88804161642ba0957f7e52edd2ac37 Mon Sep 17 00:00:00 2001 From: Vedran Kasalica Date: Tue, 3 Sep 2024 00:06:10 +0200 Subject: [PATCH 5/8] Further cleaning tests --- .github/workflows/clean-containers.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/clean-containers.yaml b/.github/workflows/clean-containers.yaml index ccf504f..302a0e4 100644 --- a/.github/workflows/clean-containers.yaml +++ b/.github/workflows/clean-containers.yaml @@ -26,5 +26,4 @@ jobs: token: ${{ secrets.GH_REPO_TOKEN }} cut-off: 2w 3d dry-run: true - keep-n-most-recent: 1 From 67cc9c9e0949af5e894b9615f0e69c0569f9adce Mon Sep 17 00:00:00 2001 From: Vedran Kasalica Date: Tue, 3 Sep 2024 00:09:08 +0200 Subject: [PATCH 6/8] Try to clean non latest only docker imgs --- .github/workflows/clean-containers.yaml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/clean-containers.yaml b/.github/workflows/clean-containers.yaml index 302a0e4..78f0642 100644 --- a/.github/workflows/clean-containers.yaml +++ b/.github/workflows/clean-containers.yaml @@ -15,15 +15,13 @@ jobs: REGISTRY: ghcr.io steps: - - name: Set REPO environment variable - run: echo "REPO=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV - - name: Delete 'PR' containers older than a week uses: snok/container-retention-policy@v3.0.0 with: account: sanctuuary - image-names: "!latest" + image-names: "!empty" token: ${{ secrets.GH_REPO_TOKEN }} + image-tags: "!latest" cut-off: 2w 3d dry-run: true From ab896949e04f2e3fb379bc697ddc0b0806df7fdd Mon Sep 17 00:00:00 2001 From: Vedran Kasalica Date: Tue, 3 Sep 2024 00:12:32 +0200 Subject: [PATCH 7/8] Fixed the GH action for cleaning containers --- .github/workflows/clean-containers.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clean-containers.yaml b/.github/workflows/clean-containers.yaml index 78f0642..302403f 100644 --- a/.github/workflows/clean-containers.yaml +++ b/.github/workflows/clean-containers.yaml @@ -23,5 +23,5 @@ jobs: token: ${{ secrets.GH_REPO_TOKEN }} image-tags: "!latest" cut-off: 2w 3d - dry-run: true + keep-n-most-recent: 2 From 445a7de10c8bacfc004d850d1fdcc41229314e1d Mon Sep 17 00:00:00 2001 From: Vedran Kasalica Date: Tue, 3 Sep 2024 00:18:54 +0200 Subject: [PATCH 8/8] Update the clean-containers action to run once per week --- .github/workflows/clean-containers.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/clean-containers.yaml b/.github/workflows/clean-containers.yaml index 302403f..e65b954 100644 --- a/.github/workflows/clean-containers.yaml +++ b/.github/workflows/clean-containers.yaml @@ -3,7 +3,7 @@ name: "Clean the old docker images" on: workflow_dispatch: # Manual trigger schedule: - - cron: "21 21 * * *" # Scheduled run + - cron: "21 21 * * 0" # Scheduled run every Sunday at 21:21 jobs: clean-ghcr: