delete-package-versions icon indicating copy to clipboard operation
delete-package-versions copied to clipboard

ignore-versions doesn't seem to work with container packages (ghcr)

Open DaveFPM opened this issue 1 year ago • 9 comments

Trying to use ignore-versions with the new support for ghcr container package types, but it doesn't seem to work. I am trying to delete beta packages when pushing into the develop branch, and non beta packages when pushing into main. But ATM it just deletes the packages regardless of the name.

My full example config is here:

name: CI

on:
  push:
    branches:
      - "**"
  pull_request:
    branches:
      - "**"

jobs:
  test:
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v3

      - name: npm install
        run: npm install

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ghcr.io
          username: ${{ github.actor }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Docker build
        if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
        run: node ./node_modules/gulp/bin/gulp.js ci-docker-build
        env:
          DEBUG: true

      - name: Docker publish
        if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
        run: node ./node_modules/gulp/bin/gulp.js ci-docker-publish
        env:
          DEBUG: true

      - name: Docker cleanup develop images
        if: github.ref == 'refs/heads/develop'
        uses: actions/delete-package-versions@v4
        with:
          package-name: 'dave-test'
          package-type: 'container'
          min-versions-to-keep: 2
          ignore-versions: '^((?!beta).)*$'

      - name: Docker cleanup production images
        if: github.ref == 'refs/heads/main'
        uses: actions/delete-package-versions@v4
        with:
          package-name: 'dave-test'
          package-type: 'container'
          min-versions-to-keep: 3
          ignore-versions: 'beta'

DaveFPM avatar Jan 20 '23 02:01 DaveFPM

Hello @DaveFPM

The ignore-versions input param filters out all versions whose names match the regex supplied. As checked from the DB, none of the version names for package name dave-test match the regex beta & hence all the versions are getting deleted as expected.

Also pls note that this action currently doesn't support filtering based on container tags & I suppose you might be looking out for something like that?

May I suggest you please go through our marketplace documentation on how this input param works?

nishthaGupta avatar Jan 20 '23 07:01 nishthaGupta

Also pls note that this action currently doesn't support filtering based on container tags & I suppose you might be looking out for something like that?

Yes, maybe thats my confusion. I would have thought it would have worked to filter "Tagged image versions".

I guess this is not the case, so more of a feature request then?

image

DaveFPM avatar Jan 22 '23 23:01 DaveFPM

@DaveFPM Yes, this can be taken as a new feature request for sure. 👍

nishthaGupta avatar Jan 25 '23 08:01 nishthaGupta

Yes filtering on container tags would be great!

dbogardus avatar Feb 07 '23 20:02 dbogardus

@mikhailkoliada I don't understand. If this doesn't filter by tags then what does it do? Tags !== versions?

To clarify, I'm trying to effectively purge my images to save space. I only need to keep main, prod-base.* and backend-build.*. Can I not achieve this with the action in its current state?

image

AlexGodbehere avatar Sep 16 '23 08:09 AlexGodbehere

May I suggest you please go through our marketplace documentation on how this input param works?

I just came to the same problem as Dave here. There is no mention in documentation anywhere that this action can not / will not parse container tags.

Could you add it please? Or even better merge #104

AtomicFS avatar Feb 21 '24 11:02 AtomicFS

@nishthaGupta is this feature being worked on? It would be great for the official action to support containers since GHCR is part of GitHub packages. The change proposed in #104 seems to work and could simply be merged to resolve these issues. cc @cwille97, @jidicula who have merged PRs on this repo recently

rbtr avatar Mar 27 '24 22:03 rbtr

It works fine, I made my own fork of actions/delete-package-versions with #104 and #119 to gain access to these features and works as expected.

AtomicFS avatar Mar 28 '24 08:03 AtomicFS

This is a surprising and annoying bug.

  1. It is not documented in the readme and
  2. There seems to be a PR that is meant to fix it open from one year ago but it hadn't landed for some reason

Can you please prioritize this as GHCR is an essential part many organizations workflow

abjrcode avatar Apr 22 '24 08:04 abjrcode