Skip to content

Commit 6d029ee

Browse files
committed
Delete the build tags with hub-tool
Ref: docker/hub-tool#198
1 parent 2001ba3 commit 6d029ee

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

.github/workflows/publish.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,13 @@ on:
1010
push:
1111
tags:
1212
- "*"
13+
branches:
14+
- "*"
1315

1416
jobs:
1517
build-image:
1618
runs-on: ubuntu-latest
19+
needs: create-final-image
1720
strategy:
1821
fail-fast: false
1922
max-parallel: 4
@@ -57,6 +60,7 @@ jobs:
5760
create-final-image:
5861
runs-on: ubuntu-latest
5962
needs: build-image
63+
name: Create the image manifest
6064
steps:
6165
- name: Login to DockerHub
6266
uses: docker/login-action@v2
@@ -77,3 +81,38 @@ jobs:
7781
run: docker manifest push docker.io/botsudo/docker-rustpython:latest
7882
- name: Inspect the manifest
7983
run: docker manifest inspect docker.io/botsudo/docker-rustpython:latest
84+
tags-cleanup:
85+
runs-on: ubuntu-latest
86+
name: Cleanup build tags
87+
steps:
88+
- name: Install Docker hub-tool
89+
run: |
90+
curl -sL https://github.com/docker/hub-tool/releases/download/v0.4.5/hub-tool-linux-amd64.tar.gz -o hub-tool-linux.tar.gz
91+
tar --strip-components=1 -xzf ./hub-tool-linux.tar.gz
92+
./hub-tool --version
93+
- name: Login hub-tool
94+
run: |
95+
# Fool the login command (https://github.com/docker/hub-tool/pull/198)
96+
# ./hub-tool login
97+
# Token commands thank to https://stackoverflow.com/a/59334315/5155484
98+
HUB_TOKEN=$(curl -s -H "Content-Type: application/json" -X POST -d "{\"username\": \"$DOCKER_USERNAME\", \"password\": \"$DOCKER_PASSWORD\"}" https://hub.docker.com/v2/users/login/ | jq -r .token)
99+
USERNAME="$(printf '%s:' "$DOCKER_USERNAME" | base64 -w0)"
100+
USER_PASS="$(printf '%s:%s' "$DOCKER_USERNAME" "$DOCKER_PASSWORD" | base64 -w0)"
101+
mkdir -p ~/.docker/
102+
printf '{"auths": {"hub-tool": {"auth": "%s"}, "hub-tool-refresh-token": {"auth": "%s"}, "hub-tool-token": { "auth": "%s", "identitytoken": "%s"}}}' \
103+
"$USER_PASS" "$USERNAME" \
104+
"$USERNAME" "$HUB_TOKEN" \
105+
> ~/.docker/config.json
106+
env:
107+
DOCKER_USERNAME: ${{ secrets.DOCKER_REPOSITORY_LOGIN }}
108+
DOCKER_PASSWORD: ${{ secrets.DOCKER_REPOSITORY_PASSWORD }}
109+
- name: Remove PR container image via hub-tool
110+
run: |
111+
./hub-tool tag rm --verbose --force docker.io/botsudo/docker-rustpython:armv6-latest || true
112+
./hub-tool tag rm --verbose --force docker.io/botsudo/docker-rustpython:armv7-latest || true
113+
./hub-tool tag rm --verbose --force docker.io/botsudo/docker-rustpython:arm64v8-latest || true
114+
./hub-tool tag rm --verbose --force docker.io/botsudo/docker-rustpython:386-latest || true
115+
./hub-tool tag rm --verbose --force docker.io/botsudo/docker-rustpython:ppc64le-latest || true
116+
./hub-tool tag rm --verbose --force docker.io/botsudo/docker-rustpython:amd64-latest || true
117+
- name: Logout hub-tool
118+
run: rm ~/.docker/config.json

0 commit comments

Comments
 (0)