From d5f3fa32486ea335db802d68fe2147fa2da69583 Mon Sep 17 00:00:00 2001 From: Mahipal <42860185+mukul975@users.noreply.github.com> Date: Wed, 15 Apr 2026 22:37:28 +0200 Subject: [PATCH] Update star.yml --- .github/workflows/star.yml | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/workflows/star.yml b/.github/workflows/star.yml index 6d961eb0..c1f03b0b 100644 --- a/.github/workflows/star.yml +++ b/.github/workflows/star.yml @@ -1,4 +1,4 @@ - +# .github/workflows/star-milestones.yml name: Star Milestone Tracker on: @@ -24,15 +24,16 @@ jobs: https://api.github.com/repos/$REPO | jq .stargazers_count) echo "Current stars: $STARS" - # Get last notified milestone - LAST_RESPONSE=$(curl -s -w "\n%{http_code}" \ + # Get last notified milestone — separate body and status code + BODY=$(curl -s -o /tmp/var_response.json -w "%{http_code}" \ -H "Authorization: token $GH_TOKEN" \ "https://api.github.com/repos/$REPO/actions/variables/LAST_STAR_MILESTONE") - HTTP_STATUS=$(echo "$LAST_RESPONSE" | tail -n1) - LAST=$(echo "$LAST_RESPONSE" | head -n1 | jq -r '.value // "0"') + HTTP_STATUS="$BODY" + echo "HTTP status: $HTTP_STATUS" - # If variable doesn't exist yet, treat as 0 - if [ "$HTTP_STATUS" = "404" ]; then + if [ "$HTTP_STATUS" = "200" ]; then + LAST=$(jq -r '.value // "0"' /tmp/var_response.json) + else LAST="0" fi echo "Last notified milestone: $LAST" @@ -40,7 +41,6 @@ jobs: # Calculate highest multiple of 500 crossed NOTIFY_MILESTONE=$(( (STARS / 500) * 500 )) NEXT=$(( (STARS / 500 + 1) * 500 )) - echo "Current milestone: $NOTIFY_MILESTONE | Next: $NEXT ($(( NEXT - STARS )) stars to go)" if [ "$NOTIFY_MILESTONE" -gt "$LAST" ] && [ "$NOTIFY_MILESTONE" -gt 0 ]; then @@ -62,9 +62,8 @@ jobs: }] }" - # Update or create the variable + # Create or update variable if [ "$HTTP_STATUS" = "404" ]; then - # Create variable curl -s -X POST \ -H "Authorization: token $GH_TOKEN" \ -H "Content-type: application/json" \ @@ -72,7 +71,6 @@ jobs: -d "{\"name\":\"LAST_STAR_MILESTONE\",\"value\":\"$NOTIFY_MILESTONE\"}" echo "Created LAST_STAR_MILESTONE = $NOTIFY_MILESTONE" else - # Update variable curl -s -X PATCH \ -H "Authorization: token $GH_TOKEN" \ -H "Content-type: application/json" \