-
Notifications
You must be signed in to change notification settings - Fork 108
20 lines (20 loc) · 1.13 KB
/
delete.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
name: delete-pr-images
on:
pull_request:
types: [closed]
jobs:
delete_tags:
name: Delete PR images from Dockerhub
runs-on: ubuntu-latest
steps:
- name: dockerhub task
env:
BRANCH: ${{ github.head_ref }}
DOCKER_USER: ${{ secrets.DockerHubUser }}
DOCKER_PASS: ${{ secrets.DockerHubToken }}
run: |
BRANCH=$(echo -n ${BRANCH} | tr -c '[:alnum:]._-' '-')
TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d '{"username": "'${DOCKER_USER}'", "password": "'${DOCKER_PASS}'"}' https://hub.docker.com/v2/users/login/ | jq -r .token)
images=("${BRANCH}-latest" "${BRANCH}-runtime" "${BRANCH}-tools" "${BRANCH}-tests-1.31" "${BRANCH}-tests-1.30" "${BRANCH}-tests-1.29" "${BRANCH}-tests-1.28" "${BRANCH}-builder")
for i in ${images[*]}; do curl --fail -sS -X DELETE -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/digitalocean/k8s-e2e-test-runner/tags/$i/; done
curl --fail -sS -X DELETE -H "Authorization: JWT ${TOKEN}" https://hub.docker.com/v2/repositories/digitalocean/do-csi-plugin-dev/tags/${BRANCH}/