From ca99bc3e9f4a7b2938a3079ae1bf54b5609da57c Mon Sep 17 00:00:00 2001 From: pmacius Date: Thu, 14 Nov 2024 11:21:18 +0100 Subject: [PATCH 1/7] OPSEXP-2893 Add step which cleans the bakery-cache tags older than given period --- .github/workflows/cleanup_images.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.github/workflows/cleanup_images.yml b/.github/workflows/cleanup_images.yml index 27a7522a..97c2c305 100644 --- a/.github/workflows/cleanup_images.yml +++ b/.github/workflows/cleanup_images.yml @@ -62,6 +62,19 @@ jobs: delete-tags: ${{ env.PR_TAGS }} dry-run: false + - name: Remove ${{ env.CACHE_REPO }} tags older than ${{ env.PERIOD }} after PR is closed + uses: dataaxiom/ghcr-cleanup-action@98b4022383d6ddb70ccbf6a378b4d8c67a60f066 # v1.0.13 + if: github.event_name == 'pull_request' + env: + PERIOD: 2 weeks + with: + token: ${{ secrets.DELETE_PACKAGES_GITHUB_TOKEN }} + owner: ${{ env.ORG }} + repository: ${{ env.REPO }} + packages: ${{ env.CACHE_REPO }} + older-than: ${{ env.PERIOD }} + dry-run: false + - name: Remove images when requested uses: dataaxiom/ghcr-cleanup-action@98b4022383d6ddb70ccbf6a378b4d8c67a60f066 # v1.0.13 if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' From f84accc12e61b933692a40373039440c9c3a4fbb Mon Sep 17 00:00:00 2001 From: pmacius Date: Thu, 14 Nov 2024 13:21:28 +0100 Subject: [PATCH 2/7] review --- .github/workflows/cleanup_images.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cleanup_images.yml b/.github/workflows/cleanup_images.yml index 97c2c305..f66ad5f6 100644 --- a/.github/workflows/cleanup_images.yml +++ b/.github/workflows/cleanup_images.yml @@ -21,6 +21,16 @@ on: required: false type: boolean default: false + clean-old-cache: + description: Delete old cache images + required: false + type: boolean + default: false + old-cache-period: + description: Period to keep cache images + required: false + type: string + default: 2 weeks env: ORG: Alfresco @@ -62,18 +72,18 @@ jobs: delete-tags: ${{ env.PR_TAGS }} dry-run: false - - name: Remove ${{ env.CACHE_REPO }} tags older than ${{ env.PERIOD }} after PR is closed + - name: Remove ${{ env.CACHE_REPO }} tags older than ${{ env.PERIOD }} when requested uses: dataaxiom/ghcr-cleanup-action@98b4022383d6ddb70ccbf6a378b4d8c67a60f066 # v1.0.13 - if: github.event_name == 'pull_request' + if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.clean-old-cache) env: - PERIOD: 2 weeks + PERIOD: ${{ github.event_name == 'workflow_dispatch' && inputs.old-cache-period || (github.event_name != 'workflow_dispatch' && '2 weeks') }} with: token: ${{ secrets.DELETE_PACKAGES_GITHUB_TOKEN }} owner: ${{ env.ORG }} repository: ${{ env.REPO }} packages: ${{ env.CACHE_REPO }} older-than: ${{ env.PERIOD }} - dry-run: false + dry-run: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run || (github.event_name != 'workflow_dispatch' && 'false') }} - name: Remove images when requested uses: dataaxiom/ghcr-cleanup-action@98b4022383d6ddb70ccbf6a378b4d8c67a60f066 # v1.0.13 From d39d089ce4c8aecff34962cb89789ccbe3f30ad3 Mon Sep 17 00:00:00 2001 From: pmacius Date: Thu, 14 Nov 2024 14:56:29 +0100 Subject: [PATCH 3/7] try with untaged set to no --- .github/workflows/cleanup_images.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cleanup_images.yml b/.github/workflows/cleanup_images.yml index f66ad5f6..3198ec38 100644 --- a/.github/workflows/cleanup_images.yml +++ b/.github/workflows/cleanup_images.yml @@ -82,6 +82,7 @@ jobs: owner: ${{ env.ORG }} repository: ${{ env.REPO }} packages: ${{ env.CACHE_REPO }} + delete-untagged: false older-than: ${{ env.PERIOD }} dry-run: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run || (github.event_name != 'workflow_dispatch' && 'false') }} From 690fe4b538c780889371c7573e17fb3332c320b7 Mon Sep 17 00:00:00 2001 From: pmacius Date: Thu, 14 Nov 2024 15:08:19 +0100 Subject: [PATCH 4/7] see the debug option --- .github/workflows/cleanup_images.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/cleanup_images.yml b/.github/workflows/cleanup_images.yml index 3198ec38..1902ac81 100644 --- a/.github/workflows/cleanup_images.yml +++ b/.github/workflows/cleanup_images.yml @@ -83,6 +83,7 @@ jobs: repository: ${{ env.REPO }} packages: ${{ env.CACHE_REPO }} delete-untagged: false + log-level: debug older-than: ${{ env.PERIOD }} dry-run: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run || (github.event_name != 'workflow_dispatch' && 'false') }} From e92d878cdf90aba68c0650dbbd2c0a9dcdfea2dd Mon Sep 17 00:00:00 2001 From: pmacius Date: Thu, 14 Nov 2024 15:08:40 +0100 Subject: [PATCH 5/7] skip other job for now --- .github/workflows/cleanup_images.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cleanup_images.yml b/.github/workflows/cleanup_images.yml index 1902ac81..78f10a52 100644 --- a/.github/workflows/cleanup_images.yml +++ b/.github/workflows/cleanup_images.yml @@ -87,15 +87,15 @@ jobs: older-than: ${{ env.PERIOD }} dry-run: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run || (github.event_name != 'workflow_dispatch' && 'false') }} - - name: Remove images when requested - uses: dataaxiom/ghcr-cleanup-action@98b4022383d6ddb70ccbf6a378b4d8c67a60f066 # v1.0.13 - if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - with: - token: ${{ secrets.DELETE_PACKAGES_GITHUB_TOKEN }} - owner: ${{ env.ORG }} - repository: ${{ env.REPO }} - packages: ${{ env.PACKAGE_NAMES }},${{ env.CACHE_REPO }} - delete-untagged: ${{ github.event_name == 'schedule' || inputs.untagged }} - delete-tags: ${{ github.event.inputs.tags }} - use-regex: true - dry-run: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run || (github.event_name != 'workflow_dispatch' && 'false') }} + # - name: Remove images when requested + # uses: dataaxiom/ghcr-cleanup-action@98b4022383d6ddb70ccbf6a378b4d8c67a60f066 # v1.0.13 + # if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + # with: + # token: ${{ secrets.DELETE_PACKAGES_GITHUB_TOKEN }} + # owner: ${{ env.ORG }} + # repository: ${{ env.REPO }} + # packages: ${{ env.PACKAGE_NAMES }},${{ env.CACHE_REPO }} + # delete-untagged: ${{ github.event_name == 'schedule' || inputs.untagged }} + # delete-tags: ${{ github.event.inputs.tags }} + # use-regex: true + # dry-run: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run || (github.event_name != 'workflow_dispatch' && 'false') }} From 0947546c9e259744c8af864fbe3ce9663ead1363 Mon Sep 17 00:00:00 2001 From: pmacius Date: Thu, 14 Nov 2024 15:26:50 +0100 Subject: [PATCH 6/7] try with keep n tagged --- .github/workflows/cleanup_images.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/cleanup_images.yml b/.github/workflows/cleanup_images.yml index 78f10a52..97ff1a00 100644 --- a/.github/workflows/cleanup_images.yml +++ b/.github/workflows/cleanup_images.yml @@ -83,7 +83,7 @@ jobs: repository: ${{ env.REPO }} packages: ${{ env.CACHE_REPO }} delete-untagged: false - log-level: debug + keep-n-tagged: 0 older-than: ${{ env.PERIOD }} dry-run: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run || (github.event_name != 'workflow_dispatch' && 'false') }} From b1a7a97a3df469d841d44a05063bca5eb5405a6b Mon Sep 17 00:00:00 2001 From: pmacius Date: Thu, 14 Nov 2024 15:37:33 +0100 Subject: [PATCH 7/7] back --- .github/workflows/cleanup_images.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/cleanup_images.yml b/.github/workflows/cleanup_images.yml index 97ff1a00..5a18c4e1 100644 --- a/.github/workflows/cleanup_images.yml +++ b/.github/workflows/cleanup_images.yml @@ -87,15 +87,15 @@ jobs: older-than: ${{ env.PERIOD }} dry-run: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run || (github.event_name != 'workflow_dispatch' && 'false') }} - # - name: Remove images when requested - # uses: dataaxiom/ghcr-cleanup-action@98b4022383d6ddb70ccbf6a378b4d8c67a60f066 # v1.0.13 - # if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' - # with: - # token: ${{ secrets.DELETE_PACKAGES_GITHUB_TOKEN }} - # owner: ${{ env.ORG }} - # repository: ${{ env.REPO }} - # packages: ${{ env.PACKAGE_NAMES }},${{ env.CACHE_REPO }} - # delete-untagged: ${{ github.event_name == 'schedule' || inputs.untagged }} - # delete-tags: ${{ github.event.inputs.tags }} - # use-regex: true - # dry-run: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run || (github.event_name != 'workflow_dispatch' && 'false') }} + - name: Remove images when requested + uses: dataaxiom/ghcr-cleanup-action@98b4022383d6ddb70ccbf6a378b4d8c67a60f066 # v1.0.13 + if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' + with: + token: ${{ secrets.DELETE_PACKAGES_GITHUB_TOKEN }} + owner: ${{ env.ORG }} + repository: ${{ env.REPO }} + packages: ${{ env.PACKAGE_NAMES }},${{ env.CACHE_REPO }} + delete-untagged: ${{ github.event_name == 'schedule' || inputs.untagged }} + delete-tags: ${{ github.event.inputs.tags }} + use-regex: true + dry-run: ${{ github.event_name == 'workflow_dispatch' && inputs.dry-run || (github.event_name != 'workflow_dispatch' && 'false') }}