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

Not able to delete multiple tags using the action #108

Open
TaniyaVincent opened this issue May 30, 2022 · 3 comments
Open

Not able to delete multiple tags using the action #108

TaniyaVincent opened this issue May 30, 2022 · 3 comments

Comments

@TaniyaVincent
Copy link

I want to pass the list of tags to be deleted as a text file. Currently, I am able to pass only one tag. Is there a way I can give multiple tags as input in this action?

      tag: '${{ steps.package.outputs.content }}'           
@electrofelix
Copy link

A workaround is to use a matrix job, you can take a list of the tags and pass it to jq to convert to a json array:

  generate-delete-docker-images-matrix:
    outputs:
      matrix: ${{ steps.matrix.outputs.tags }}
    steps:
.... <earlier step uses docker/metadata-action to generate tags>
      -
        name: Generate matrix
        id: matrix
        run: |
          TAGS="$(echo "${{ steps.generate-docker-metadata.outputs.tags }}" | jq -c --raw-input 'split(",")')"
          echo "tags=${TAGS}" >> ${GITHUB_OUTPUT}

  delete-docker-images:
    needs: generate-delete-docker-images-matrix
    runs-on: ubuntu-22.04
    strategy:
      matrix:
        tag: ${{ fromJSON(needs.generate-delete-docker-images-matrix.outputs.matrix) }}
    steps:
      - name: Delete image
        uses: bots-house/[email protected]
        with:
          owner: ${{ github.repository_owner }}
          name: ${{ github.event.repository.name }}
          token: ${{ secrets.GITHUB_TOKEN }}
          tag: ${{ matrix.tag }}

@vlussenburg
Copy link
Collaborator

@TaniyaVincent Is the workaround sufficient for your use case? Can we close this ticket?

@rohanmars
Copy link

I fixed this in a new project. https://github.com/dataaxiom/ghcr-cleanup-action which also supports untagging, so it doesn't delete the image if there are still tags on it.

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

4 participants