-
Notifications
You must be signed in to change notification settings - Fork 21
198 lines (164 loc) · 8.02 KB
/
daily-digest.yml
File metadata and controls
198 lines (164 loc) · 8.02 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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
name: Daily Project Digest
on:
schedule:
- cron: '0 7 * * *' # 07:00 UTC daily
workflow_dispatch: {} # Allow manual trigger
permissions:
issues: write
jobs:
digest:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0 # Full history for git log
- name: Gather repository data
env:
GH_TOKEN: ${{ github.token }}
run: |
REPO="${{ github.repository }}"
YESTERDAY=$(date -u -d '1 day ago' +%Y-%m-%dT00:00:00Z)
TODAY=$(date -u +%Y-%m-%d)
YESTERDAY_DATE=$(date -u -d '1 day ago' +%Y-%m-%d)
echo "=== Gathering data for $YESTERDAY_DATE ===" >&2
# --- Stars and Forks ---
gh api "repos/$REPO" --jq '{
stars: .stargazers_count,
forks: .forks_count,
open_issues: .open_issues_count,
watchers: .subscribers_count
}' > /tmp/repo-stats.json
# --- Commits in last 24h ---
git log --since="$YESTERDAY" --format='- [`%h`](https://github.com/'"$REPO"'/commit/%H) %s (%an)' > /tmp/commits.txt || true
# --- Pull requests merged in last 24h ---
gh pr list --repo "$REPO" --state merged --search "merged:>=$YESTERDAY_DATE" \
--json number,title,author,mergedAt,url --limit 50 \
--jq '.[] | "- [#\(.number)](\(.url)) \(.title) (@\(.author.login))"' \
> /tmp/merged-prs.txt || true
# --- Pull requests opened in last 24h ---
gh pr list --repo "$REPO" --state open --search "created:>=$YESTERDAY_DATE" \
--json number,title,author,url --limit 50 \
--jq '.[] | "- [#\(.number)](\(.url)) \(.title) (@\(.author.login))"' \
> /tmp/opened-prs.txt || true
# --- Currently open PRs ---
gh pr list --repo "$REPO" --state open \
--json number,title,author,url --limit 50 \
--jq '.[] | "- [#\(.number)](\(.url)) \(.title) (@\(.author.login))"' \
> /tmp/open-prs.txt || true
# --- Issues opened in last 24h ---
gh issue list --repo "$REPO" --state open --search "created:>=$YESTERDAY_DATE" \
--json number,title,author,url,labels --limit 50 \
--jq '.[] | "- [#\(.number)](\(.url)) \(.title) (@\(.author.login))"' \
> /tmp/opened-issues.txt || true
# --- Issues closed in last 24h ---
gh issue list --repo "$REPO" --state closed --search "closed:>=$YESTERDAY_DATE" \
--json number,title,url --limit 50 \
--jq '.[] | "- [#\(.number)](\(.url)) \(.title)"' \
> /tmp/closed-issues.txt || true
# --- Currently open issues ---
OPEN_ISSUE_COUNT=$(gh issue list --repo "$REPO" --state open --limit 1 --json number --jq 'length')
echo "$OPEN_ISSUE_COUNT" > /tmp/open-issue-count.txt
# --- Dependency updates (go.sum changes) ---
git diff --name-only HEAD~5..HEAD 2>/dev/null | grep -E "go\.(mod|sum)" > /tmp/dep-changes.txt || true
# --- CI status of latest run ---
gh run list --repo "$REPO" --branch main --limit 3 \
--json conclusion,name,updatedAt,url \
--jq '.[] | "- \(.conclusion // "in_progress") — \(.name) [\(.updatedAt)](\(.url))"' \
> /tmp/ci-status.txt || true
- name: Build digest
run: |
YESTERDAY_DATE=$(date -u -d '1 day ago' +%Y-%m-%d)
TODAY=$(date -u +%Y-%m-%d)
STARS=$(jq -r '.stars' /tmp/repo-stats.json)
FORKS=$(jq -r '.forks' /tmp/repo-stats.json)
WATCHERS=$(jq -r '.watchers' /tmp/repo-stats.json)
OPEN_ISSUES=$(cat /tmp/open-issue-count.txt)
cat > /tmp/digest-data.txt <<DATAEOF
# Daily Project Digest: $TODAY
## Repository Stats
| Metric | Count |
|--------|-------|
| Stars | $STARS |
| Forks | $FORKS |
| Watchers | $WATCHERS |
| Open issues | $OPEN_ISSUES |
## Commits (last 24h)
$(cat /tmp/commits.txt 2>/dev/null | head -30)
$([ ! -s /tmp/commits.txt ] && echo "_No commits in the last 24 hours._")
## Pull Requests Merged (last 24h)
$(cat /tmp/merged-prs.txt 2>/dev/null)
$([ ! -s /tmp/merged-prs.txt ] && echo "_No PRs merged._")
## Pull Requests Opened (last 24h)
$(cat /tmp/opened-prs.txt 2>/dev/null)
$([ ! -s /tmp/opened-prs.txt ] && echo "_No new PRs._")
## Currently Open PRs
$(cat /tmp/open-prs.txt 2>/dev/null)
$([ ! -s /tmp/open-prs.txt ] && echo "_No open PRs._")
## Issues Opened (last 24h)
$(cat /tmp/opened-issues.txt 2>/dev/null)
$([ ! -s /tmp/opened-issues.txt ] && echo "_No new issues._")
## Issues Closed (last 24h)
$(cat /tmp/closed-issues.txt 2>/dev/null)
$([ ! -s /tmp/closed-issues.txt ] && echo "_No issues closed._")
## CI Status (latest runs on main)
$(cat /tmp/ci-status.txt 2>/dev/null)
## Dependency Changes (last 5 commits)
$(cat /tmp/dep-changes.txt 2>/dev/null)
$([ ! -s /tmp/dep-changes.txt ] && echo "_No dependency changes._")
DATAEOF
- name: Generate AI summary
env:
OPENROUTER_API_KEY: ${{ secrets.OPENROUTER_API_KEY }}
run: |
if [ -z "$OPENROUTER_API_KEY" ]; then
echo "::warning::OPENROUTER_API_KEY not set, posting raw digest"
cp /tmp/digest-data.txt /tmp/digest-final.md
exit 0
fi
jq -n --rawfile data /tmp/digest-data.txt '{
model: "nvidia/nemotron-3-super-120b-a12b:free",
messages: [
{
role: "system",
content: "You are a project digest assistant for mxcli, a Go CLI tool for reading and modifying Mendix application projects (.mpr files). Generate a concise daily digest from the raw data provided. Structure your response as:\n\n1. **Highlights** (1-3 bullet points of the most important changes)\n2. **Code Changes** (summarize commits by theme, not individually)\n3. **Pull Requests** (merged, opened, pending review)\n4. **Issues** (new, closed, total open)\n5. **Repository Health** (stars, forks, CI status)\n6. **Action Items** (anything that needs attention: failing CI, stale PRs, unanswered issues)\n\nKeep it concise — this is a daily scan, not a detailed report. Use markdown formatting."
},
{
role: "user",
content: $data
}
],
max_tokens: 3000,
temperature: 0.3
}' > /tmp/ai-request.json
HTTP_CODE=$(curl -s -w "%{http_code}" -o /tmp/ai-response.json -X POST \
-H "Authorization: Bearer $OPENROUTER_API_KEY" \
-H "Content-Type: application/json" \
-d @/tmp/ai-request.json \
https://openrouter.ai/api/v1/chat/completions)
if [ "$HTTP_CODE" = "200" ]; then
SUMMARY=$(jq -r '.choices[0].message.content // empty' /tmp/ai-response.json)
if [ -n "$SUMMARY" ]; then
echo "$SUMMARY" > /tmp/digest-final.md
else
cp /tmp/digest-data.txt /tmp/digest-final.md
fi
else
echo "::warning::OpenRouter returned HTTP $HTTP_CODE, using raw digest"
cp /tmp/digest-data.txt /tmp/digest-final.md
fi
- name: Post digest as issue
env:
GH_TOKEN: ${{ github.token }}
run: |
TODAY=$(date -u +%Y-%m-%d)
{
cat /tmp/digest-final.md
echo ""
echo "---"
echo "*Daily digest generated automatically — [workflow source](${{ github.server_url }}/${{ github.repository }}/blob/main/.github/workflows/daily-digest.yml)*"
} > /tmp/issue-body.md
gh issue create \
--repo "${{ github.repository }}" \
--title "Daily Digest: $TODAY" \
--body-file /tmp/issue-body.md \
--label "digest"