This repository has been archived by the owner on Oct 14, 2024. It is now read-only.
Container Image Cleanup #5323
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: Container Image Cleanup | |
on: | |
pull_request: | |
types: | |
- closed | |
schedule: | |
# At minute 0 on every day-of-week from Monday through Friday. | |
# https://crontab.guru/#0_*_*_*_1-5 | |
- cron: '0 * * * 1-5' | |
workflow_dispatch: | |
inputs: | |
cut-off: | |
required: false | |
type: string | |
description: | | |
The timezone-aware datetime you want to delete container versions that are older than. | |
The parsed datetime must contain a timezone. | |
The `dateparser` is ued to parse the cut-off specified. See: [dateparser](https://dateparser.readthedocs.io/en/latest/) | |
default: '14 days ago UTC' | |
dry-run: | |
required: false | |
type: boolean | |
description: Prints output showing images which would be deleted but does not actually delete any images. | |
default: true | |
env: | |
images: vmclarity-apiserver-dev,vmclarity-orchestrator-dev,vmclarity-cli-dev,vmclarity-ui-backend-dev,vmclarity-ui-dev | |
permissions: | |
packages: write | |
jobs: | |
pull-request: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
name: Cleanup container images for Pull Request | |
steps: | |
- name: Remove images for PR#${{ github.event.pull_request.number }} | |
uses: snok/container-retention-policy@b56f4ff7539c1f94f01e5dc726671cd619aa8072 # v2.2.1 | |
with: | |
image-names: ${{ env.images }} | |
cut-off: 1 second ago UTC | |
timestamp-to-use: created_at | |
account-type: org | |
org-name: openclarity | |
token: ${{ secrets.PAT }} | |
filter-tags: ${{ format( 'pr{0}-*', github.event.pull_request.number) }} | |
dry-run: false | |
schedule: | |
if: github.event_name == 'schedule' | |
runs-on: ubuntu-latest | |
name: Cleanup stale container images | |
steps: | |
- name: Remove stale images | |
uses: snok/container-retention-policy@b56f4ff7539c1f94f01e5dc726671cd619aa8072 # v2.2.1 | |
with: | |
image-names: ${{ env.images }} | |
cut-off: 7 days ago UTC | |
timestamp-to-use: created_at | |
account-type: org | |
org-name: openclarity | |
token: ${{ secrets.PAT }} | |
filter-include-untagged: true | |
dry-run: false | |
dispatch: | |
if: github.event_name == 'workflow_dispatch' | |
runs-on: ubuntu-latest | |
name: Cleanup stale container images | |
steps: | |
- name: Remove stale images | |
uses: snok/container-retention-policy@b56f4ff7539c1f94f01e5dc726671cd619aa8072 # v2.2.1 | |
with: | |
image-names: ${{ env.images }} | |
cut-off: ${{ inputs.cut-off }} | |
timestamp-to-use: created_at | |
account-type: org | |
org-name: openclarity | |
token: ${{ secrets.PAT }} | |
filter-include-untagged: true | |
dry-run: ${{ inputs.dry-run }} |