|
| 1 | +name: Delete image from registry |
| 2 | + |
| 3 | +env: |
| 4 | + OWNER: ${{ github.repository_owner }} |
| 5 | + |
| 6 | +on: |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + image: |
| 10 | + description: Image name to delete (e.g. base-notebook) |
| 11 | + required: true |
| 12 | + type: choice |
| 13 | + options: |
| 14 | + - docker-stacks-foundation |
| 15 | + - base-notebook |
| 16 | + - minimal-notebook |
| 17 | + - scipy-notebook |
| 18 | + - r-notebook |
| 19 | + - julia-notebook |
| 20 | + - tensorflow-notebook |
| 21 | + - pytorch-notebook |
| 22 | + - datascience-notebook |
| 23 | + - pyspark-notebook |
| 24 | + - all-spark-notebook |
| 25 | + tag: |
| 26 | + description: Image tag to delete (e.g. 2024-01-01 or latest) |
| 27 | + required: true |
| 28 | + type: string |
| 29 | + registry: |
| 30 | + description: Registry to delete from |
| 31 | + required: true |
| 32 | + type: choice |
| 33 | + default: quay |
| 34 | + options: |
| 35 | + - dockerhub |
| 36 | + - quay |
| 37 | + - both |
| 38 | + |
| 39 | +jobs: |
| 40 | + image-delete: |
| 41 | + runs-on: ubuntu-24.04 |
| 42 | + environment: registry-image-delete |
| 43 | + permissions: |
| 44 | + contents: read |
| 45 | + timeout-minutes: 5 |
| 46 | + if: (github.repository_owner == 'jupyter' || github.repository_owner == 'mathbunnyru') && github.ref == 'refs/heads/main' |
| 47 | + |
| 48 | + steps: |
| 49 | + - name: Install skopeo 📦 |
| 50 | + run: sudo apt-get update && sudo apt-get install -y skopeo |
| 51 | + |
| 52 | + - name: Login to Docker Hub 🔐 |
| 53 | + if: inputs.registry == 'dockerhub' || inputs.registry == 'both' |
| 54 | + env: |
| 55 | + DOCKERHUB_USERNAME: ${{ secrets.REGISTRY_USERNAME }} |
| 56 | + DOCKERHUB_TOKEN: ${{ secrets.REGISTRY_TOKEN }} |
| 57 | + run: | |
| 58 | + skopeo login docker.io \ |
| 59 | + --username "$DOCKERHUB_USERNAME" \ |
| 60 | + --password "$DOCKERHUB_TOKEN" |
| 61 | +
|
| 62 | + - name: Login to Quay.io 🔐 |
| 63 | + if: inputs.registry == 'quay' || inputs.registry == 'both' |
| 64 | + run: | |
| 65 | + skopeo login quay.io \ |
| 66 | + --username ${{ secrets.QUAY_USERNAME }} \ |
| 67 | + --password ${{ secrets.QUAY_ROBOT_TOKEN }} |
| 68 | +
|
| 69 | + - name: Delete tag from Docker Hub 🗑️ |
| 70 | + if: inputs.registry == 'dockerhub' || inputs.registry == 'both' |
| 71 | + run: | |
| 72 | + skopeo delete \ |
| 73 | + docker://docker.io/${{ env.OWNER }}/${{ inputs.image }}:${{ inputs.tag }} |
| 74 | + echo "Successfully deleted ${{ env.OWNER }}/${{ inputs.image }}:${{ inputs.tag }} from Docker Hub" |
| 75 | +
|
| 76 | + - name: Delete tag from Quay.io 🗑️ |
| 77 | + if: inputs.registry == 'quay' || inputs.registry == 'both' |
| 78 | + run: | |
| 79 | + skopeo delete \ |
| 80 | + docker://quay.io/${{ env.OWNER }}/${{ inputs.image }}:${{ inputs.tag }} |
| 81 | + echo "Successfully deleted ${{ env.OWNER }}/${{ inputs.image }}:${{ inputs.tag }} from Quay.io" |
0 commit comments