Repository navigation
Daily Metrics Dashboard #86
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Daily Metrics Dashboard | |
| # Tracks Sipcode's growth metrics every day: | |
| # - npm download counts (yesterday, last 7 days, last 30 days) | |
| # - GitHub repo stats (stars, forks, watchers, open issues) | |
| # Posts the daily snapshot as a comment on a single persistent dashboard issue, | |
| # so you can scroll the issue to see the full growth history. | |
| # | |
| # Created 2026-06-18 as part of the launch automation stack. | |
| # Zero cost: GitHub Actions is free for public repos. | |
| on: | |
| schedule: | |
| # Runs daily at 14:00 UTC (07:00 PT, 19:30 IST). Catches the previous | |
| # full day's npm data which finalizes around 12:00 UTC. | |
| - cron: '0 14 * * *' | |
| workflow_dispatch: # Allows manual trigger from the Actions tab | |
| permissions: | |
| contents: read | |
| issues: write | |
| jobs: | |
| collect-and-post: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Fetch npm download counts | |
| id: npm | |
| run: | | |
| # Yesterday's downloads | |
| YESTERDAY=$(date -d "yesterday" '+%Y-%m-%d') | |
| DAILY=$(curl -s "https://api.npmjs.org/downloads/point/$YESTERDAY/sipcode" | jq -r '.downloads // 0') | |
| # Last 7 days | |
| WEEK_END=$(date -d "yesterday" '+%Y-%m-%d') | |
| WEEK_START=$(date -d "8 days ago" '+%Y-%m-%d') | |
| WEEKLY=$(curl -s "https://api.npmjs.org/downloads/range/$WEEK_START:$WEEK_END/sipcode" | jq -r '.downloads | map(.downloads) | add // 0') | |
| # Last 30 days | |
| MONTH_END=$(date -d "yesterday" '+%Y-%m-%d') | |
| MONTH_START=$(date -d "31 days ago" '+%Y-%m-%d') | |
| MONTHLY=$(curl -s "https://api.npmjs.org/downloads/range/$MONTH_START:$MONTH_END/sipcode" | jq -r '.downloads | map(.downloads) | add // 0') | |
| echo "daily=$DAILY" >> $GITHUB_OUTPUT | |
| echo "weekly=$WEEKLY" >> $GITHUB_OUTPUT | |
| echo "monthly=$MONTHLY" >> $GITHUB_OUTPUT | |
| # Latest published version | |
| LATEST=$(curl -s https://registry.npmjs.org/sipcode/latest | jq -r '.version') | |
| echo "version=$LATEST" >> $GITHUB_OUTPUT | |
| - name: Fetch GitHub repo stats | |
| id: gh | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| REPO_DATA=$(gh api repos/${{ github.repository }}) | |
| STARS=$(echo "$REPO_DATA" | jq -r '.stargazers_count') | |
| FORKS=$(echo "$REPO_DATA" | jq -r '.forks_count') | |
| WATCHERS=$(echo "$REPO_DATA" | jq -r '.subscribers_count') | |
| OPEN_ISSUES=$(echo "$REPO_DATA" | jq -r '.open_issues_count') | |
| echo "stars=$STARS" >> $GITHUB_OUTPUT | |
| echo "forks=$FORKS" >> $GITHUB_OUTPUT | |
| echo "watchers=$WATCHERS" >> $GITHUB_OUTPUT | |
| echo "open_issues=$OPEN_ISSUES" >> $GITHUB_OUTPUT | |
| - name: Find or create dashboard issue | |
| id: dashboard | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Ensure label exists (idempotent — won't fail if already created) | |
| gh label create "metrics-dashboard" \ | |
| --repo ${{ github.repository }} \ | |
| --color "5B4FCF" \ | |
| --description "Auto-managed: Sipcode daily metrics dashboard" 2>/dev/null || true | |
| # Look for an existing issue with the label | |
| EXISTING=$(gh issue list \ | |
| --repo ${{ github.repository }} \ | |
| --label "metrics-dashboard" \ | |
| --state open \ | |
| --limit 1 \ | |
| --json number \ | |
| --jq '.[0].number // ""') | |
| if [ -z "$EXISTING" ]; then | |
| # Create the persistent dashboard issue. `gh issue create` returns | |
| # the issue URL on stdout; we parse the trailing number. | |
| URL=$(gh issue create \ | |
| --repo ${{ github.repository }} \ | |
| --title "📊 Sipcode Metrics Dashboard" \ | |
| --label "metrics-dashboard" \ | |
| --body "Daily npm + GitHub stats. The first comment is the most recent day.") | |
| NEW_ISSUE=$(echo "$URL" | grep -oE '[0-9]+$') | |
| echo "issue=$NEW_ISSUE" >> $GITHUB_OUTPUT | |
| else | |
| echo "issue=$EXISTING" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Post today's snapshot as comment | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| TODAY=$(date -u '+%Y-%m-%d') | |
| BODY="## 📊 $TODAY | |
| **npm** | |
| | Window | Downloads | | |
| |---|---| | |
| | Yesterday | ${{ steps.npm.outputs.daily }} | | |
| | Last 7 days | ${{ steps.npm.outputs.weekly }} | | |
| | Last 30 days | ${{ steps.npm.outputs.monthly }} | | |
| | Latest published | v${{ steps.npm.outputs.version }} | | |
| **GitHub** | |
| | Metric | Count | | |
| |---|---| | |
| | ⭐ Stars | ${{ steps.gh.outputs.stars }} | | |
| | 🍴 Forks | ${{ steps.gh.outputs.forks }} | | |
| | 👀 Watchers | ${{ steps.gh.outputs.watchers }} | | |
| | 🔴 Open issues | ${{ steps.gh.outputs.open_issues }} | | |
| --- | |
| *Auto-generated by [\`daily-metrics.yml\`](https://github.com/${{ github.repository }}/actions/workflows/daily-metrics.yml)*" | |
| gh issue comment ${{ steps.dashboard.outputs.issue }} \ | |
| --repo ${{ github.repository }} \ | |
| --body "$BODY" | |
| - name: Heartbeat to Healthchecks (success) | |
| # Only fires if all previous steps succeeded. If any failed, | |
| # this step is skipped, Healthchecks notices the missed ping, | |
| # and sends an email alert within the 6h grace window. | |
| run: curl -fsS -m 10 --retry 3 https://hc-ping.com/846d7741-389c-4d8b-b3b5-7351a10f13ea |