Skip to content

updated workflow

updated workflow #3

Workflow file for this run

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