Skip to content

Cleanup main images

Cleanup main images #5

name: Cleanup main images
on:
schedule:
- cron: '5 1 * * *'
workflow_dispatch:
env:
REGISTRY: ghcr.io/openmcp-project
IMAGE_NAME: mcp-ui-frontend
FULL_IMAGE_NAME: openmcp-project/mcp-ui-frontend
KEEP_X_IMAGES: 5
jobs:
clean:
name: 'Clean main images'
runs-on: ubuntu-latest
permissions:
packages: write
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: List images before cleanup (debug)
run: |
echo "Listing images before cleanup:"
gh api -H "Accept: application/vnd.github+json" \
/users/${{ github.repository_owner }}/packages/container/${{ env.IMAGE_NAME }}/versions | jq '.[].metadata.container.tags'
env:
GH_TOKEN: ${{ github.token }}
- name: Delete old main branch images
uses: actions/delete-package-versions@v5
with:
package-name: ${{ env.IMAGE_NAME }}
package-type: 'container'
min-versions-to-keep: ${{ env.KEEP_X_IMAGES }}
ignore-versions: '^(?!main-).*$'
- name: List images after cleanup (debug)
run: |
echo "Listing images after cleanup:"
gh api -H "Accept: application/vnd.github+json" \
/users/${{ github.repository_owner }}/packages/container/${{ env.IMAGE_NAME }}/versions | jq '.[].metadata.container.tags'
env:
GH_TOKEN: ${{ github.token }}