Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
DaveFPM opened this issue Jan 20, 2023 · 9 comments
Open

Comments

@DaveFPM
Copy link

DaveFPM commented Jan 20, 2023

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'
@nishthaGupta
Copy link
Contributor

nishthaGupta commented Jan 20, 2023

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?

@DaveFPM
Copy link
Author

DaveFPM commented Jan 22, 2023

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

@nishthaGupta
Copy link
Contributor

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

@dbogardus
Copy link

Yes filtering on container tags would be great!

@AlexGodbehere
Copy link

AlexGodbehere commented Sep 16, 2023

@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

@AtomicFS
Copy link

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

@rbtr
Copy link

rbtr commented Mar 27, 2024

@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

@AtomicFS
Copy link

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.

@abjrcode
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants