-
Notifications
You must be signed in to change notification settings - Fork 3
165 lines (140 loc) · 6.23 KB
/
Copy pathlaunch-week-digest.yml
File metadata and controls
165 lines (140 loc) · 6.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
name: Launch Week Daily Digest
# Posts a comprehensive daily digest during launch week (T-7 to T+7 window).
# Auto-deactivates outside the launch window so it does not spam.
#
# Digest includes:
# - npm downloads (yesterday, week to date)
# - GitHub stars + new stars in last 24h
# - New issues opened in last 24h
# - New PRs opened/merged in last 24h
# - Top issue/PR by reactions
#
# Edit LAUNCH_DATE below before launch.
#
# Created 2026-06-18.
on:
schedule:
# Daily at 22:00 UTC (15:00 PT, 03:30 IST next day)
# End-of-day digest for the US-Pacific working window.
- cron: '0 22 * * *'
workflow_dispatch:
permissions:
contents: read
issues: write
pull-requests: read
env:
LAUNCH_DATE: "2026-06-24" # Tuesday; edit if launch date shifts
WINDOW_BEFORE_DAYS: 7 # T-7
WINDOW_AFTER_DAYS: 7 # T+7
jobs:
digest:
runs-on: ubuntu-latest
steps:
- name: Check if in launch window
id: window
run: |
TODAY=$(date -u '+%Y-%m-%d')
LAUNCH_TS=$(date -d "$LAUNCH_DATE" '+%s')
TODAY_TS=$(date -d "$TODAY" '+%s')
DIFF_DAYS=$(( (TODAY_TS - LAUNCH_TS) / 86400 ))
if [ $DIFF_DAYS -ge $((-WINDOW_BEFORE_DAYS)) ] && [ $DIFF_DAYS -le $WINDOW_AFTER_DAYS ]; then
echo "in_window=true" >> $GITHUB_OUTPUT
if [ $DIFF_DAYS -lt 0 ]; then
echo "label=T$DIFF_DAYS" >> $GITHUB_OUTPUT
elif [ $DIFF_DAYS -eq 0 ]; then
echo "label=T-0 (LAUNCH DAY)" >> $GITHUB_OUTPUT
else
echo "label=T+$DIFF_DAYS" >> $GITHUB_OUTPUT
fi
else
echo "in_window=false" >> $GITHUB_OUTPUT
echo "Outside launch window (today is $DIFF_DAYS days from $LAUNCH_DATE), skipping."
fi
- name: Fetch npm downloads
if: steps.window.outputs.in_window == 'true'
id: npm
run: |
YESTERDAY=$(date -d "yesterday" '+%Y-%m-%d')
DAILY=$(curl -s "https://api.npmjs.org/downloads/point/$YESTERDAY/sipcode" | jq -r '.downloads // 0')
WEEK_END=$(date -d "yesterday" '+%Y-%m-%d')
WEEK_START=$(date -d "$LAUNCH_DATE" '+%Y-%m-%d')
if [ "$WEEK_END" \< "$WEEK_START" ]; then WEEK_START="$WEEK_END"; fi
WEEK_TOTAL=$(curl -s "https://api.npmjs.org/downloads/range/$WEEK_START:$WEEK_END/sipcode" | jq -r '.downloads | map(.downloads) | add // 0')
echo "daily=$DAILY" >> $GITHUB_OUTPUT
echo "since_launch=$WEEK_TOTAL" >> $GITHUB_OUTPUT
- name: Fetch GitHub repo + last-24h activity
if: steps.window.outputs.in_window == 'true'
id: gh
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
REPO_DATA=$(gh api repos/${{ github.repository }})
STARS=$(echo "$REPO_DATA" | jq -r '.stargazers_count')
echo "stars=$STARS" >> $GITHUB_OUTPUT
# Issues opened in last 24h
CUTOFF=$(date -u -d "24 hours ago" '+%Y-%m-%dT%H:%M:%SZ')
NEW_ISSUES=$(gh api "search/issues?q=repo:${{ github.repository }}+is:issue+created:>$CUTOFF" --jq '.total_count // 0')
NEW_PRS=$(gh api "search/issues?q=repo:${{ github.repository }}+is:pr+created:>$CUTOFF" --jq '.total_count // 0')
MERGED_PRS=$(gh api "search/issues?q=repo:${{ github.repository }}+is:pr+is:merged+merged:>$CUTOFF" --jq '.total_count // 0')
echo "new_issues=$NEW_ISSUES" >> $GITHUB_OUTPUT
echo "new_prs=$NEW_PRS" >> $GITHUB_OUTPUT
echo "merged_prs=$MERGED_PRS" >> $GITHUB_OUTPUT
- name: Find or create launch-digest issue
if: steps.window.outputs.in_window == 'true'
id: digest_issue
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Ensure label exists (idempotent)
gh label create "launch-digest" \
--repo ${{ github.repository }} \
--color "28C840" \
--description "Auto-managed: Sipcode launch week digest" 2>/dev/null || true
EXISTING=$(gh issue list \
--repo ${{ github.repository }} \
--label "launch-digest" \
--state open \
--limit 1 \
--json number \
--jq '.[0].number // ""')
if [ -z "$EXISTING" ]; then
URL=$(gh issue create \
--repo ${{ github.repository }} \
--title "🚀 Sipcode Launch Week Digest (target $LAUNCH_DATE)" \
--label "launch-digest" \
--body "Daily launch-week summary. 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 digest
if: steps.window.outputs.in_window == 'true'
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
TODAY=$(date -u '+%Y-%m-%d')
BODY="## 🚀 ${{ steps.window.outputs.label }} — $TODAY
**npm**
| Window | Downloads |
|---|---|
| Yesterday | ${{ steps.npm.outputs.daily }} |
| Since launch | ${{ steps.npm.outputs.since_launch }} |
**GitHub (last 24h)**
| Metric | Count |
|---|---|
| ⭐ Total stars | ${{ steps.gh.outputs.stars }} |
| 🔵 New issues opened | ${{ steps.gh.outputs.new_issues }} |
| 🟢 New PRs opened | ${{ steps.gh.outputs.new_prs }} |
| 🟣 PRs merged | ${{ steps.gh.outputs.merged_prs }} |
**Reminders for ${{ steps.window.outputs.label }}**
See \`launch-day-choreography.md\` in private notes for today's specific actions.
---
*Auto-generated by [\`launch-week-digest.yml\`](https://github.com/${{ github.repository }}/actions/workflows/launch-week-digest.yml)*"
gh issue comment ${{ steps.digest_issue.outputs.issue }} \
--repo ${{ github.repository }} \
--body "$BODY"
- name: Heartbeat to Healthchecks (success)
# Pings even when outside the launch window (a no-op run is still
# successful). Only fires if all previous steps succeeded.
run: curl -fsS -m 10 --retry 3 https://hc-ping.com/ce76cc07-977e-469a-b564-f9716e496254