From 860f83445aab352d45d9a5f9b027276de5c9c0c3 Mon Sep 17 00:00:00 2001 From: AB Date: Fri, 7 Nov 2025 15:34:22 +0200 Subject: [PATCH] Readme CI --- .gitea/workflows/update-readme.yaml | 30 +++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/update-readme.yaml b/.gitea/workflows/update-readme.yaml index fae94dd..dcf0186 100644 --- a/.gitea/workflows/update-readme.yaml +++ b/.gitea/workflows/update-readme.yaml @@ -96,16 +96,27 @@ jobs: EOF # Create PR via API - RESPONSE=$(curl -s -X POST \ + echo "Making API request to: $GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/pulls" + echo "Request body:" + cat /tmp/pr_body.json + + RESPONSE=$(curl -s -w "\nHTTP_CODE:%{http_code}" -X POST \ -H "Authorization: token $GITEA_TOKEN" \ -H "Content-Type: application/json" \ -d @/tmp/pr_body.json \ "$GITEA_URL/api/v1/repos/$GITEA_OWNER/$GITEA_REPO/pulls") - # Extract PR number and URL from response - PR_NUMBER=$(echo "$RESPONSE" | grep -o '"number":[0-9]*' | head -1 | cut -d':' -f2) + # Extract HTTP code and response body + HTTP_CODE=$(echo "$RESPONSE" | grep "HTTP_CODE:" | cut -d':' -f2) + RESPONSE_BODY=$(echo "$RESPONSE" | sed '/HTTP_CODE:/d') - if [ -n "$PR_NUMBER" ]; then + echo "API Response (HTTP $HTTP_CODE):" + echo "$RESPONSE_BODY" + + # Extract PR number and URL from response + PR_NUMBER=$(echo "$RESPONSE_BODY" | grep -o '"number":[0-9]*' | head -1 | cut -d':' -f2) + + if [ -n "$PR_NUMBER" ] && [ "$HTTP_CODE" = "201" ]; then echo "✅ Pull Request created successfully!" echo "📝 PR #$PR_NUMBER" echo "🔗 URL: $GITEA_URL/$GITEA_OWNER/$GITEA_REPO/pulls/$PR_NUMBER" @@ -114,8 +125,15 @@ jobs: echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT echo "pr_url=$GITEA_URL/$GITEA_OWNER/$GITEA_REPO/pulls/$PR_NUMBER" >> $GITHUB_OUTPUT else - echo "âš ī¸ Failed to create Pull Request" - echo "Response: $RESPONSE" + echo "âš ī¸ Failed to create Pull Request (HTTP $HTTP_CODE)" + echo "Response: $RESPONSE_BODY" + + # Check if PR already exists + if echo "$RESPONSE_BODY" | grep -q "already exists"; then + echo "â„šī¸ PR already exists for this branch" + exit 0 + fi + exit 1 fi