Create star.yml

This commit is contained in:
Mahipal
2026-04-15 19:15:45 +02:00
committed by GitHub
parent 9e8a8cda80
commit 780757902b
+59
View File
@@ -0,0 +1,59 @@
# .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: |
STARS=$(curl -s -H "Authorization: token $GH_TOKEN" \
https://api.github.com/repos/$REPO | jq .stargazers_count)
echo "Current stars: $STARS"
LAST=$(curl -s -H "Authorization: token $GH_TOKEN" \
"https://api.github.com/repos/$REPO/actions/variables/LAST_STAR_MILESTONE" \
| jq -r '.value // "0"')
echo "Last notified milestone: $LAST"
# Highest multiple of 500 crossed but not yet notified
NOTIFY_MILESTONE=$(( (STARS / 500) * 500 ))
if [ "$NOTIFY_MILESTONE" -gt "$LAST" ] && [ "$NOTIFY_MILESTONE" -gt 0 ]; then
echo "🎉 New milestone: $NOTIFY_MILESTONE"
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}
]
}]
}"
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\"}"
else
NEXT=$(( (STARS / 500 + 1) * 500 ))
echo "No new milestone. Next at $NEXT stars ($(( NEXT - STARS )) to go)"
fi