Delete old ghcr images #773
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-latest | |
steps: | |
- name: Delete images related to closed PR (1) | |
id: run-pr-1 | |
continue-on-error: true | |
uses: snok/container-retention-policy@v2 | |
with: | |
image-names: cloud-server*, iotivity-lite* | |
cut-off: now UTC | |
account-type: org | |
org-name: iotivity | |
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-pr-2 | |
if: ${{ steps.run-pr-1.outcome == 'failure' }} | |
continue-on-error: true | |
uses: snok/container-retention-policy@v2 | |
with: | |
image-names: cloud-server*, iotivity-lite* | |
cut-off: now UTC | |
account-type: org | |
org-name: iotivity | |
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-pr-2.outcome == 'failure' }} | |
continue-on-error: true | |
uses: snok/container-retention-policy@v2 | |
with: | |
image-names: cloud-server*, iotivity-lite* | |
cut-off: now UTC | |
account-type: org | |
org-name: iotivity | |
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-latest | |
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: | |
token: ${{ secrets.GHCR_CLEANUP_PAT }} | |
- name: Delete stale or untagged images (2) | |
id: run-2 | |
if: ${{ steps.run-1.outcome == 'failure' }} | |
with: | |
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: | |
token: ${{ secrets.GHCR_CLEANUP_PAT }} | |
delay: 60 |