mirror of
https://github.com/mukul975/Anthropic-Cybersecurity-Skills.git
synced 2026-08-03 01:10:18 +03:00
Update star.yml
This commit is contained in:
+40
-13
@@ -1,4 +1,4 @@
|
|||||||
# .github/workflows/star-milestones.yml
|
|
||||||
name: Star Milestone Tracker
|
name: Star Milestone Tracker
|
||||||
|
|
||||||
on:
|
on:
|
||||||
@@ -19,21 +19,34 @@ jobs:
|
|||||||
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
|
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
|
||||||
REPO: mukul975/Anthropic-Cybersecurity-Skills
|
REPO: mukul975/Anthropic-Cybersecurity-Skills
|
||||||
run: |
|
run: |
|
||||||
|
# Get current star count
|
||||||
STARS=$(curl -s -H "Authorization: token $GH_TOKEN" \
|
STARS=$(curl -s -H "Authorization: token $GH_TOKEN" \
|
||||||
https://api.github.com/repos/$REPO | jq .stargazers_count)
|
https://api.github.com/repos/$REPO | jq .stargazers_count)
|
||||||
echo "Current stars: $STARS"
|
echo "Current stars: $STARS"
|
||||||
|
|
||||||
LAST=$(curl -s -H "Authorization: token $GH_TOKEN" \
|
# Get last notified milestone
|
||||||
"https://api.github.com/repos/$REPO/actions/variables/LAST_STAR_MILESTONE" \
|
LAST_RESPONSE=$(curl -s -w "\n%{http_code}" \
|
||||||
| jq -r '.value // "0"')
|
-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"')
|
||||||
|
|
||||||
|
# If variable doesn't exist yet, treat as 0
|
||||||
|
if [ "$HTTP_STATUS" = "404" ]; then
|
||||||
|
LAST="0"
|
||||||
|
fi
|
||||||
echo "Last notified milestone: $LAST"
|
echo "Last notified milestone: $LAST"
|
||||||
|
|
||||||
# Highest multiple of 500 crossed but not yet notified
|
# Calculate highest multiple of 500 crossed
|
||||||
NOTIFY_MILESTONE=$(( (STARS / 500) * 500 ))
|
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
|
if [ "$NOTIFY_MILESTONE" -gt "$LAST" ] && [ "$NOTIFY_MILESTONE" -gt 0 ]; then
|
||||||
echo "🎉 New milestone: $NOTIFY_MILESTONE"
|
echo "🎉 New milestone hit: $NOTIFY_MILESTONE"
|
||||||
|
|
||||||
|
# Send Slack notification
|
||||||
curl -X POST "$SLACK_WEBHOOK" \
|
curl -X POST "$SLACK_WEBHOOK" \
|
||||||
-H 'Content-type: application/json' \
|
-H 'Content-type: application/json' \
|
||||||
-d "{
|
-d "{
|
||||||
@@ -43,17 +56,31 @@ jobs:
|
|||||||
\"fields\": [
|
\"fields\": [
|
||||||
{\"title\": \"Milestone\", \"value\": \"$NOTIFY_MILESTONE stars 🎯\", \"short\": true},
|
{\"title\": \"Milestone\", \"value\": \"$NOTIFY_MILESTONE stars 🎯\", \"short\": true},
|
||||||
{\"title\": \"Current Stars\", \"value\": \"$STARS ⭐\", \"short\": true},
|
{\"title\": \"Current Stars\", \"value\": \"$STARS ⭐\", \"short\": true},
|
||||||
{\"title\": \"Repo\", \"value\": \"$REPO\", \"short\": false}
|
{\"title\": \"Repo\", \"value\": \"$REPO\", \"short\": false},
|
||||||
|
{\"title\": \"Link\", \"value\": \"https://github.com/$REPO\", \"short\": false}
|
||||||
]
|
]
|
||||||
}]
|
}]
|
||||||
}"
|
}"
|
||||||
|
|
||||||
curl -s -X PATCH \
|
# Update or create the variable
|
||||||
-H "Authorization: token $GH_TOKEN" \
|
if [ "$HTTP_STATUS" = "404" ]; then
|
||||||
-H "Content-type: application/json" \
|
# Create variable
|
||||||
"https://api.github.com/repos/$REPO/actions/variables/LAST_STAR_MILESTONE" \
|
curl -s -X POST \
|
||||||
-d "{\"name\":\"LAST_STAR_MILESTONE\",\"value\":\"$NOTIFY_MILESTONE\"}"
|
-H "Authorization: token $GH_TOKEN" \
|
||||||
|
-H "Content-type: application/json" \
|
||||||
|
"https://api.github.com/repos/$REPO/actions/variables" \
|
||||||
|
-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" \
|
||||||
|
"https://api.github.com/repos/$REPO/actions/variables/LAST_STAR_MILESTONE" \
|
||||||
|
-d "{\"name\":\"LAST_STAR_MILESTONE\",\"value\":\"$NOTIFY_MILESTONE\"}"
|
||||||
|
echo "Updated LAST_STAR_MILESTONE = $NOTIFY_MILESTONE"
|
||||||
|
fi
|
||||||
|
|
||||||
else
|
else
|
||||||
NEXT=$(( (STARS / 500 + 1) * 500 ))
|
|
||||||
echo "No new milestone. Next at $NEXT stars ($(( NEXT - STARS )) to go)"
|
echo "No new milestone. Next at $NEXT stars ($(( NEXT - STARS )) to go)"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user