Delete old ghcr images #957
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Delete old ghcr images | |
on: | |
schedule: | |
- cron: "15 1 * * *" # every day at 1:15am | |
pull_request: | |
types: [closed] | |
workflow_dispatch: | |
jobs: | |
pull-request-ghcr-cleanup: | |
if: ${{ github.event_name == 'pull_request' }} | |
name: Delete images related to closed PR | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Delete images related to closed PR (1) | |
id: run-1 | |
continue-on-error: true | |
uses: snok/container-retention-policy@v2 | |
with: | |
image-names: hub/* | |
cut-off: now UTC | |
account-type: org | |
org-name: plgd-dev | |
filter-tags: vnext-pr${{ github.event.pull_request.number }}* | |
token: ${{ secrets.GHCR_CLEANUP_PAT }} | |
token-type: pat | |
- name: Delete images related to closed PR (2) | |
id: run-2 | |
if: ${{ steps.run-1.outcome == 'failure' }} | |
continue-on-error: true | |
uses: snok/container-retention-policy@v2 | |
with: | |
image-names: hub/* | |
cut-off: now UTC | |
account-type: org | |
org-name: plgd-dev | |
filter-tags: vnext-pr${{ github.event.pull_request.number }}* | |
token: ${{ secrets.GHCR_CLEANUP_PAT }} | |
token-type: pat | |
- name: Delete images related to closed PR (3) | |
if: ${{ steps.run-2.outcome == 'failure' }} | |
uses: snok/container-retention-policy@v2 | |
with: | |
image-names: hub/* | |
cut-off: now UTC | |
account-type: org | |
org-name: plgd-dev | |
filter-tags: vnext-pr${{ github.event.pull_request.number }}* | |
token: ${{ secrets.GHCR_CLEANUP_PAT }} | |
token-type: pat | |
nightly-ghcr-cleanup: | |
if: ${{ github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' }} | |
name: Delete stale or untagged images | |
runs-on: ubuntu-24.04 | |
strategy: | |
fail-fast: false | |
matrix: | |
include: | |
- package_name: http-gateway | |
- package_name: bundle | |
- package_name: resource-aggregate | |
- package_name: resource-directory | |
- package_name: coap-gateway | |
- package_name: cloud2cloud-connector | |
- package_name: cloud2cloud-gateway | |
- package_name: certificate-authority | |
- package_name: grpc-gateway | |
- package_name: identity-store | |
- package_name: mock-oauth-server | |
- package_name: test-cloud-server | |
- package_name: cert-tool | |
- package_name: grpc-reflection | |
- package_name: snippet-service | |
- package_name: mongodb-standby-tool | |
- package_name: mongodb-admin-tool | |
- package_name: m2m-oauth-server | |
- package_name: device-provisioning-service | |
- package_name: test-device-provisioning-service | |
steps: | |
- name: Checkout local actions | |
uses: actions/checkout@v4 | |
- name: Delete stale or untagged images (1) | |
id: run-1 | |
continue-on-error: true | |
uses: ./.github/actions/cleanup-stale | |
with: | |
package_name: hub/${{ matrix.package_name }} | |
token: ${{ secrets.GHCR_CLEANUP_PAT }} | |
- name: Delete stale or untagged images (2) | |
id: run-2 | |
if: ${{ steps.run-1.outcome == 'failure' }} | |
with: | |
package_name: hub/${{ matrix.package_name }} | |
token: ${{ secrets.GHCR_CLEANUP_PAT }} | |
delay: 60 | |
continue-on-error: true | |
uses: ./.github/actions/cleanup-stale | |
- name: Delete stale or untagged images (3) | |
if: ${{ steps.run-2.outcome == 'failure' }} | |
uses: ./.github/actions/cleanup-stale | |
with: | |
package_name: hub/${{ matrix.package_name }} | |
token: ${{ secrets.GHCR_CLEANUP_PAT }} | |
delay: 60 |