From 257b932e6fa23f07a211e7dff75f12b2e0329b2d Mon Sep 17 00:00:00 2001 From: saxix Date: Thu, 20 Jun 2024 13:50:26 +0200 Subject: [PATCH] 2024-06-20 13:50 - updates --- .github/workflows/delete_image.yml | 46 ++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 .github/workflows/delete_image.yml diff --git a/.github/workflows/delete_image.yml b/.github/workflows/delete_image.yml new file mode 100644 index 00000000..59ab6790 --- /dev/null +++ b/.github/workflows/delete_image.yml @@ -0,0 +1,46 @@ +name: Branch Deleted +on: delete +jobs: + delete: + if: github.event.ref_type == 'branch' + runs-on: ubuntu-latest + steps: + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + - name: Define linked test image name + id: image_name + run: | + echo "name=${{vars.DOCKER_IMAGE}}:test-${{steps.meta.outputs.version}}" >> $GITHUB_OUTPUT + - name: Clean up + shell: bash + run: | + registry="https://registry-1.docker.io" + name=${{steps.image_name.outputs.name}} + curl -v -sSL -X DELETE "http://${registry}/v2/${name}/manifests/$( + curl -sSL -I \ + -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \ + "http://${registry}/v2/${name}/manifests/$( + curl -sSL "http://${registry}/v2/${name}/tags/list" | jq -r '.tags[0]' + )" \ + | awk '$1 == "Docker-Content-Digest:" { print $2 }' \ + | tr -d $'\r' \ + )" + - name: Define linked image name + id: image_name + run: | + echo "name=${{vars.DOCKER_IMAGE}}:${{steps.meta.outputs.version}}" >> $GITHUB_OUTPUT + - name: Clean up + shell: bash + run: | + registry="https://registry-1.docker.io" + name=${{steps.image_name.outputs.name}} + curl -v -sSL -X DELETE "http://${registry}/v2/${name}/manifests/$( + curl -sSL -I \ + -H "Accept: application/vnd.docker.distribution.manifest.v2+json" \ + "http://${registry}/v2/${name}/manifests/$( + curl -sSL "http://${registry}/v2/${name}/tags/list" | jq -r '.tags[0]' + )" \ + | awk '$1 == "Docker-Content-Digest:" { print $2 }' \ + | tr -d $'\r' \ + )"