mirror of
https://github.com/mukul975/Anthropic-Cybersecurity-Skills.git
synced 2026-06-11 05:34:55 +03:00
85 lines
3.3 KiB
YAML
85 lines
3.3 KiB
YAML
# .github/workflows/star-milestones.yml
|
|
name: Star Milestone Tracker
|
|
|
|
on:
|
|
schedule:
|
|
- cron: '0 * * * *'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
actions: write
|
|
|
|
jobs:
|
|
check-stars:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check star count & notify milestones
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
|
|
REPO: mukul975/Anthropic-Cybersecurity-Skills
|
|
run: |
|
|
# Get current star count
|
|
STARS=$(curl -s -H "Authorization: token $GH_TOKEN" \
|
|
https://api.github.com/repos/$REPO | jq .stargazers_count)
|
|
echo "Current stars: $STARS"
|
|
|
|
# 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="$BODY"
|
|
echo "HTTP status: $HTTP_STATUS"
|
|
|
|
if [ "$HTTP_STATUS" = "200" ]; then
|
|
LAST=$(jq -r '.value // "0"' /tmp/var_response.json)
|
|
else
|
|
LAST="0"
|
|
fi
|
|
echo "Last notified milestone: $LAST"
|
|
|
|
# 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
|
|
echo "🎉 New milestone hit: $NOTIFY_MILESTONE"
|
|
|
|
# Send Slack notification
|
|
curl -X POST "$SLACK_WEBHOOK" \
|
|
-H 'Content-type: application/json' \
|
|
-d "{
|
|
\"text\": \"⭐ *Star Milestone Reached!*\",
|
|
\"attachments\": [{
|
|
\"color\": \"#FFD700\",
|
|
\"fields\": [
|
|
{\"title\": \"Milestone\", \"value\": \"$NOTIFY_MILESTONE stars 🎯\", \"short\": true},
|
|
{\"title\": \"Current Stars\", \"value\": \"$STARS ⭐\", \"short\": true},
|
|
{\"title\": \"Repo\", \"value\": \"$REPO\", \"short\": false},
|
|
{\"title\": \"Link\", \"value\": \"https://github.com/$REPO\", \"short\": false}
|
|
]
|
|
}]
|
|
}"
|
|
|
|
# Create or update variable
|
|
if [ "$HTTP_STATUS" = "404" ]; then
|
|
curl -s -X POST \
|
|
-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
|
|
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
|
|
echo "No new milestone. Next at $NEXT stars ($(( NEXT - STARS )) to go)"
|
|
fi
|