Update star.yml

This commit is contained in:
Mahipal
2026-04-15 22:37:28 +02:00
committed by GitHub
parent 91a087aacc
commit d5f3fa3248
+9 -11
View File
@@ -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" \