Skip to content

Commit 24a3be8

Browse files
committed
chore(ci): add workflow to delete contaminated Docker Hub tags
1 parent c8e50fa commit 24a3be8

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
name: Delete Contaminated Docker Hub Tags
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
delete-tags:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- name: Delete Docker Hub tags
11+
env:
12+
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
13+
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
14+
run: |
15+
set -e
16+
# Get a JWT for the Hub API
17+
TOKEN=$(curl -s -X POST "https://hub.docker.com/v2/users/login/" \
18+
-H "Content-Type: application/json" \
19+
-d "{\"username\":\"${DOCKERHUB_USERNAME}\",\"password\":\"${DOCKERHUB_TOKEN}\"}" \
20+
| python3 -c "import sys,json; print(json.load(sys.stdin).get('token',''))")
21+
if [ -z "$TOKEN" ]; then
22+
echo "ERROR: failed to get Hub API token"
23+
exit 1
24+
fi
25+
echo "Got Hub API token (length ${#TOKEN})"
26+
for tag in latest dev v1.1.4 v1.1.3 v1.1.0 v1.0 v1.1.0-beta.1 v1.0.1; do
27+
echo "--- deleting $tag ---"
28+
code=$(curl -s -o /dev/null -w "%{http_code}" -X DELETE \
29+
"https://hub.docker.com/v2/repositories/${DOCKERHUB_USERNAME}/lux-mon/tags/${tag}/" \
30+
-H "Authorization: JWT ${TOKEN}")
31+
echo " HTTP $code"
32+
done

0 commit comments

Comments
 (0)