Skip to content

Analytics

Analytics #1

Workflow file for this run

name: Analytics
on:
schedule:
- cron: '0 5 * * 0' # Every Sunday at 5 AM
workflow_dispatch: # Manual trigger
jobs:
analytics:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '18'
- name: Get repository analytics
id: analytics
run: |
echo "Gathering repository analytics..."
# Get repository stats
REPO_DATA=$(curl -s "https://api.github.com/repos/${{ github.repository }}")
# Extract metrics
STARS=$(echo "$REPO_DATA" | jq -r '.stargazers_count')
FORKS=$(echo "$REPO_DATA" | jq -r '.forks_count')
WATCHERS=$(echo "$REPO_DATA" | jq -r '.watchers_count')
OPEN_ISSUES=$(echo "$REPO_DATA" | jq -r '.open_issues_count')
# Get recent commits
COMMITS=$(curl -s "https://api.github.com/repos/${{ github.repository }}/commits?since=$(date -d '7 days ago' -Iseconds)" | jq 'length')
# Get recent releases
RELEASES=$(curl -s "https://api.github.com/repos/${{ github.repository }}/releases" | jq 'length')
# Get contributors
CONTRIBUTORS=$(curl -s "https://api.github.com/repos/${{ github.repository }}/contributors" | jq 'length')
# Get languages
LANGUAGES=$(curl -s "https://api.github.com/repos/${{ github.repository }}/languages" | jq -r 'to_entries | map("\(.key): \(.value)") | join(", ")')
# Output variables
echo "stars=$STARS" >> $GITHUB_OUTPUT
echo "forks=$FORKS" >> $GITHUB_OUTPUT
echo "watchers=$WATCHERS" >> $GITHUB_OUTPUT
echo "open_issues=$OPEN_ISSUES" >> $GITHUB_OUTPUT
echo "commits=$COMMITS" >> $GITHUB_OUTPUT
echo "releases=$RELEASES" >> $GITHUB_OUTPUT
echo "contributors=$CONTRIBUTORS" >> $GITHUB_OUTPUT
echo "languages=$LANGUAGES" >> $GITHUB_OUTPUT
- name: Generate analytics report
run: |
echo "Generating analytics report..."
# Create analytics report
cat > analytics-report.md << EOF
# Repository Analytics Report
Generated on: $(date)
## 📊 Key Metrics
- **Stars:** ${{ steps.analytics.outputs.stars }}
- **Forks:** ${{ steps.analytics.outputs.forks }}
- **Watchers:** ${{ steps.analytics.outputs.watchers }}
- **Open Issues:** ${{ steps.analytics.outputs.open_issues }}
- **Recent Commits (7 days):** ${{ steps.analytics.outputs.commits }}
- **Total Releases:** ${{ steps.analytics.outputs.releases }}
- **Contributors:** ${{ steps.analytics.outputs.contributors }}
## 🗣️ Languages Used
${{ steps.analytics.outputs.languages }}
## 📈 Growth Trends
### Weekly Growth
- New stars this week: [Calculate from previous week]
- New forks this week: [Calculate from previous week]
- New issues this week: [Calculate from previous week]
### Monthly Growth
- New stars this month: [Calculate from previous month]
- New forks this month: [Calculate from previous month]
- New contributors this month: [Calculate from previous month]
## 🎯 Recommendations
Based on the current metrics:
1. **Engagement:** [Recommendations based on engagement metrics]
2. **Growth:** [Recommendations for growth]
3. **Community:** [Recommendations for community building]
4. **Development:** [Recommendations for development]
## 📋 Action Items
- [ ] Review and respond to open issues
- [ ] Engage with community feedback
- [ ] Plan next release
- [ ] Update documentation
- [ ] Review contribution guidelines
---
*This report is generated automatically every week.*
EOF
echo "Analytics report generated: analytics-report.md"
- name: Upload analytics report
uses: actions/upload-artifact@v4
with:
name: analytics-report-${{ github.run_id }}
path: analytics-report.md
retention-days: 30
- name: Send analytics notification
uses: sarisia/actions-status-discord@v1
if: env.DISCORD_WEBHOOK
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
with:
webhook: ${{ secrets.DISCORD_WEBHOOK }}
status: info
title: "📊 Weekly Analytics Report"
description: |
Weekly repository analytics have been generated.
**Key Metrics:**
- ⭐ Stars: ${{ steps.analytics.outputs.stars }}
- 🔀 Forks: ${{ steps.analytics.outputs.forks }}
- 👀 Watchers: ${{ steps.analytics.outputs.watchers }}
- 🐛 Open Issues: ${{ steps.analytics.outputs.open_issues }}
- 📝 Recent Commits: ${{ steps.analytics.outputs.commits }}
- 🎉 Releases: ${{ steps.analytics.outputs.releases }}
- 👥 Contributors: ${{ steps.analytics.outputs.contributors }}
Full report available in artifacts.
- name: Create analytics issue
if: github.event_name == 'workflow_dispatch'
uses: actions/github-script@v7
with:
script: |
const report = require('fs').readFileSync('analytics-report.md', 'utf8');
await github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: `📊 Analytics Report - ${new Date().toISOString().split('T')[0]}`,
body: report,
labels: ['analytics', 'report']
});