-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (58 loc) · 2.24 KB
/
Copy pathdocker.yml
File metadata and controls
67 lines (58 loc) · 2.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: Docker
on:
push:
branches: [master]
workflow_dispatch:
env:
IMAGE: flugmaschine/hand-tracking-drawing
jobs:
build-push:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64
push: true
tags: |
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:${{ github.sha }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Update Docker Hub description
env:
HUB_USER: ${{ secrets.DOCKERHUB_USERNAME }}
HUB_PASS: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
set -euo pipefail
code=$(jq -n --arg i "$HUB_USER" --arg s "$HUB_PASS" '{identifier:$i,secret:$s}' \
| curl -sS -o auth.json -w '%{http_code}' -X POST https://hub.docker.com/v2/auth/token \
-H 'Content-Type: application/json' --data-binary @-)
if [ "$code" != "200" ]; then
echo "auth failed: HTTP $code"
jq -r '.detail // .message // .' auth.json || cat auth.json
exit 1
fi
token=$(jq -r .access_token auth.json)
rm -f auth.json
code=$(jq -n --rawfile d DOCKERHUB.md '{full_description:$d}' \
| curl -sS -o patch.json -w '%{http_code}' \
-X PATCH "https://hub.docker.com/v2/repositories/$HUB_USER/hand-tracking-drawing/" \
-H "Authorization: Bearer $token" \
-H 'Content-Type: application/json' --data-binary @-)
if [ "$code" != "200" ]; then
echo "description update failed: HTTP $code"
jq -r '.detail // .message // .' patch.json || cat patch.json
if [ "$code" = "403" ]; then
echo "DOCKERHUB_TOKEN needs the 'Read, Write, Delete' permission (scope repo:admin)"
fi
exit 1
fi
jq -r '"description updated: \(.name) (\(.full_description | length) chars)"' patch.json
rm -f patch.json