diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index 480cf70..b1f02f8 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -390,49 +390,57 @@ jobs: if ! command -v jq &> /dev/null; then apt-get update && apt-get install -y jq || apk add --no-cache jq || true fi - + echo "🚀 Starting update README on Docker Hub..." - + TOKEN=$(curl -s -X POST "https://hub.docker.com/v2/users/login/" \ -H "Content-Type: application/json" \ -d "{\"username\": \"${{ secrets.DOCKERHUB_USERNAME }}\", \"password\": \"${{ secrets.DOCKERHUB_TOKEN }}\"}" | jq -r .token) - + if [ "$TOKEN" == "null" ] || [ -z "$TOKEN" ]; then echo "❌ Error: No login-token available. Check your credentials!" exit 1 fi - + REPO_PURE="${{ steps.prep.outputs.repo_pure }}" DH_USER="${{ secrets.DOCKERHUB_USERNAME }}" - + GITEA_URL="${{ steps.prep.outputs.image_name }}" + DH_URL="${DH_USER}/${REPO_PURE}" + SHORT_DESC=$(echo -e "${{ env.DESCRIPTION }}" | head -n 1 | cut -c 1-100) [ -z "$SHORT_DESC" ] && SHORT_DESC="Docker Image for $REPO_PURE" - - echo "📦 Processing README.md (${REPO_PURE})..." - + + echo "📦 Processing README.md for Docker Hub (${DH_URL})..." + + # Erstelle temporäre README für Docker Hub, in der die Gitea-URL durch den Docker Hub Image-Namen ersetzt wird + sed "s|${GITEA_URL}|${DH_URL}|g" README.md > README_DH.md + jq -n \ --arg desc "$SHORT_DESC" \ - --rawfile full_desc README.md \ + --rawfile full_desc README_DH.md \ '{description: $desc, full_description: $full_desc}' > payload.json - + echo "📤 Sending data to Docker Hub API..." RESPONSE=$(curl -s -w "\n%{http_code}" -X PATCH \ "https://hub.docker.com/v2/repositories/${DH_USER}/${REPO_PURE}/" \ -H "Authorization: JWT ${TOKEN}" \ -H "Content-Type: application/json" \ -d @payload.json) - + HTTP_STATUS=$(echo "$RESPONSE" | tail -n 1) BODY=$(echo "$RESPONSE" | head -n -1) - + if [ "$HTTP_STATUS" -eq 200 ]; then - echo "✅ README update successfull (HTTP 200)." + echo "✅ README update successful (HTTP 200)." else echo "❌ Error on update! HTTP Status: $HTTP_STATUS" echo "Answer from Docker Hub: $BODY" exit 1 fi + # Temporäre Datei aufräumen + rm -f README_DH.md + - name: Commit, Tag and Push Changes if: steps.check_changes.outputs.should_build == 'true' run: |