ghcr-delete-image-action
ghcr-delete-image-action copied to clipboard
Not able to delete multiple tags using the action
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 }}'
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 }}
@TaniyaVincent Is the workaround sufficient for your use case? Can we close this ticket?
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.