diff --git a/.gitea/workflows/build-and-push.yaml b/.gitea/workflows/build-and-push.yaml index f2fc961..fcf5ff6 100644 --- a/.gitea/workflows/build-and-push.yaml +++ b/.gitea/workflows/build-and-push.yaml @@ -237,11 +237,11 @@ jobs: # 1. Authentifizierter Download der Templates TOKEN="${{ secrets.RUNNER_TOKEN }}" curl -sSLf -H "Authorization: token $TOKEN" \ - "https://git.pi-farm.de/pi-farm/templates/raw/branch/dev/README.template" \ + "https://git.pi-farm.de/pi-farm/templates/raw/branch/main/README.template" \ -o README.template || echo "Warnung: README Template konnte nicht geladen werden" curl -sSLf -H "Authorization: token $TOKEN" \ - "https://git.pi-farm.de/pi-farm/templates/raw/branch/dev/docker-compose.template" \ + "https://git.pi-farm.de/pi-farm/templates/raw/branch/main/docker-compose.template" \ -o docker-compose.template || echo "Warnung: Compose Template konnte nicht geladen werden" # 2. Sicherheitsprüfung auf HTML-Login-Seite @@ -377,76 +377,76 @@ jobs: echo "EOF" } >> $GITHUB_ENV - - name: Push README to Docker Hub - if: steps.check_changes.outputs.should_build == 'true' && contains(steps.prep.outputs.push_targets, 'dockerhub') - run: | - 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 }}" - - 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})..." - - jq -n \ - --arg desc "$SHORT_DESC" \ - --rawfile full_desc README.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)." - else - echo "❌ Error on update! HTTP Status: $HTTP_STATUS" - echo "Answer from Docker Hub: $BODY" - exit 1 - fi - - - name: Commit, Tag and Push Changes - if: steps.check_changes.outputs.should_build == 'true' - run: | - git config --local user.email "action@pi-farm.de" - git config --local user.name "Gitea Action" - - git add VERSION.history README.md docker-compose.yml - - git diff --quiet && git diff --staged --quiet || git commit -m "${{ env.FINAL_MSG }} [skip ci]" - - TARGET_TAG="${{ steps.prep.outputs.docker_tag }}" - git tag -f "$TARGET_TAG" - - if [[ "${{ gitea.ref }}" == refs/tags/* ]]; then - echo "🏷️ Build aus Tag getriggert: $TARGET_TAG" - git push -f origin "$TARGET_TAG" - else - echo "🌿 Build aus Branch/Schedule getriggert: ${{ gitea.ref_name }}" - git push origin HEAD:${{ gitea.ref_name }} - git push -f origin "$TARGET_TAG" - fi + - name: Push README to Docker Hub + if: steps.check_changes.outputs.should_build == 'true' && contains(steps.prep.outputs.push_targets, 'dockerhub') + run: | + 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 }}" + + 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})..." + + jq -n \ + --arg desc "$SHORT_DESC" \ + --rawfile full_desc README.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)." + else + echo "❌ Error on update! HTTP Status: $HTTP_STATUS" + echo "Answer from Docker Hub: $BODY" + exit 1 + fi + + - name: Commit, Tag and Push Changes + if: steps.check_changes.outputs.should_build == 'true' + run: | + git config --local user.email "action@pi-farm.de" + git config --local user.name "Gitea Action" + + git add VERSION.history README.md docker-compose.yml + + git diff --quiet && git diff --staged --quiet || git commit -m "${{ env.FINAL_MSG }} [skip ci]" + + TARGET_TAG="${{ steps.prep.outputs.docker_tag }}" + git tag -f "$TARGET_TAG" + + if [[ "${{ gitea.ref }}" == refs/tags/* ]]; then + echo "🏷️ Build aus Tag getriggert: $TARGET_TAG" + git push -f origin "$TARGET_TAG" + else + echo "🌿 Build aus Branch/Schedule getriggert: ${{ gitea.ref_name }}" + git push origin HEAD:${{ gitea.ref_name }} + git push -f origin "$TARGET_TAG" + fi - name: Cleanup Temporary Tags on Docker Hub if: steps.check_changes.outputs.should_build == 'true' && contains(steps.prep.outputs.push_targets, 'dockerhub')