Skip to content

Commit 8447714

Browse files
committed
ci(dev-call): add weekly Discourse post automation
1 parent 3c1aeea commit 8447714

File tree

1 file changed

+247
-0
lines changed

1 file changed

+247
-0
lines changed
Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
name: PX4 Weekly Dev Call Post
2+
3+
on:
4+
schedule:
5+
# Every Monday at 10:00 UTC (2 days before Wednesday call)
6+
# Format: minute hour day-of-month month day-of-week
7+
# day-of-week: 0=Sun 1=Mon 2=Tue 3=Wed 4=Thu 5=Fri 6=Sat
8+
- cron: '0 10 * * 1'
9+
workflow_dispatch:
10+
11+
jobs:
12+
post-dev-call:
13+
runs-on: ubuntu-latest
14+
env:
15+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
16+
DISCOURSE_API_KEY: ${{ secrets.DISCOURSE_API_KEY }}
17+
DISCOURSE_USER: farhang
18+
DISCOURSE_URL: https://discuss.px4.io
19+
# DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
20+
CATEGORY_ID: 39
21+
22+
steps:
23+
- name: Calculate dates
24+
id: dates
25+
run: |
26+
NEXT_WED=$(date -d "next Wednesday" +"%Y-%m-%d")
27+
DISPLAY_DATE=$(date -d "$NEXT_WED" +"%b %d, %Y")
28+
WEEK_AGO=$(date -d "7 days ago" +"%Y-%m-%d")
29+
echo "call_date=$NEXT_WED" >> "$GITHUB_OUTPUT"
30+
echo "display_date=$DISPLAY_DATE" >> "$GITHUB_OUTPUT"
31+
echo "week_ago=$WEEK_AGO" >> "$GITHUB_OUTPUT"
32+
33+
- name: Fetch merged PRs (last 7 days)
34+
id: prs
35+
run: |
36+
SINCE=${{ steps.dates.outputs.week_ago }}
37+
38+
MERGED=$(gh pr list --repo PX4/PX4-Autopilot \
39+
--state merged \
40+
--search "merged:>=${SINCE}" \
41+
--json number,title,author,url \
42+
--limit 50)
43+
44+
NEEDS_REVIEW=$(gh pr list --repo PX4/PX4-Autopilot \
45+
--state open \
46+
--search "review:none created:>=${SINCE}" \
47+
--json number,title,author,url \
48+
--limit 20)
49+
50+
echo "$MERGED" | jq -r '
51+
if length == 0 then "- None this week"
52+
else .[] |
53+
"- [#\(.number) \(.title)](\(.url)) by @\(.author.login)"
54+
end' > /tmp/merged_prs.md
55+
56+
echo "$NEEDS_REVIEW" | jq -r '
57+
if length == 0 then "- None pending"
58+
else .[] |
59+
"- [#\(.number) \(.title)](\(.url)) by @\(.author.login)"
60+
end' > /tmp/review_prs.md
61+
62+
echo "merged_count=$(echo "$MERGED" | jq 'length')" >> "$GITHUB_OUTPUT"
63+
echo "review_count=$(echo "$NEEDS_REVIEW" | jq 'length')" >> "$GITHUB_OUTPUT"
64+
65+
- name: Fetch new issues (last 7 days)
66+
id: issues
67+
run: |
68+
SINCE=${{ steps.dates.outputs.week_ago }}
69+
70+
BUGS=$(gh issue list --repo PX4/PX4-Autopilot \
71+
--state all \
72+
--search "created:>=${SINCE} label:bug" \
73+
--json number,title,url \
74+
--limit 20)
75+
76+
OTHER=$(gh issue list --repo PX4/PX4-Autopilot \
77+
--state all \
78+
--search "created:>=${SINCE} -label:bug" \
79+
--json number,title,url \
80+
--limit 20)
81+
82+
echo "$BUGS" | jq -r '
83+
if length == 0 then "- No new bugs"
84+
else .[] |
85+
"- [#\(.number) \(.title)](\(.url))"
86+
end' > /tmp/bug_issues.md
87+
88+
echo "$OTHER" | jq -r '
89+
if length == 0 then "- None"
90+
else .[] |
91+
"- [#\(.number) \(.title)](\(.url))"
92+
end' > /tmp/other_issues.md
93+
94+
echo "bug_count=$(echo "$BUGS" | jq 'length')" >> "$GITHUB_OUTPUT"
95+
96+
- name: Build post body
97+
run: |
98+
CALL_DATE=${{ steps.dates.outputs.call_date }}
99+
MERGED_COUNT=${{ steps.prs.outputs.merged_count }}
100+
REVIEW_COUNT=${{ steps.prs.outputs.review_count }}
101+
BUG_COUNT=${{ steps.issues.outputs.bug_count }}
102+
103+
cat > /tmp/post_body.md << 'EOF'
104+
# PX4 Sync / Q&A - [date=__CALL_DATE__ time=17:00:00 timezone="CET"]
105+
106+
**This week:** __MERGED_COUNT__ PRs merged | __REVIEW_COUNT__ awaiting review | __BUG_COUNT__ new bugs
107+
108+
---
109+
110+
## Announcements
111+
112+
113+
---
114+
115+
## Events
116+
117+
118+
---
119+
120+
## Release
121+
122+
**Current tag:** [v1.17.0-rc2](https://github.com/PX4/PX4-Autopilot/releases/tag/v1.17.0-rc2)
123+
**Target date:** June 2026
124+
**Flight Tracker:** [v1.17 Release Testing](https://github.com/PX4/PX4-Autopilot/issues/26271)
125+
126+
**Updates:**
127+
128+
129+
**Issues:**
130+
131+
132+
**Decisions:**
133+
134+
135+
---
136+
137+
## PRs Merged This Week
138+
139+
__MERGED_PRS__
140+
141+
## PRs Awaiting Review
142+
143+
__REVIEW_PRS__
144+
145+
---
146+
147+
## New Bug Reports
148+
149+
__BUG_ISSUES__
150+
151+
## Other New Issues
152+
153+
__OTHER_ISSUES__
154+
155+
---
156+
157+
## Q&A
158+
159+
160+
---
161+
162+
## Action Items
163+
164+
EOF
165+
166+
sed -i "s|__CALL_DATE__|${CALL_DATE}|g" /tmp/post_body.md
167+
sed -i "s|__MERGED_COUNT__|${MERGED_COUNT}|g" /tmp/post_body.md
168+
sed -i "s|__REVIEW_COUNT__|${REVIEW_COUNT}|g" /tmp/post_body.md
169+
sed -i "s|__BUG_COUNT__|${BUG_COUNT}|g" /tmp/post_body.md
170+
171+
python3 << 'PYEOF'
172+
with open('/tmp/post_body.md', 'r') as f:
173+
content = f.read()
174+
175+
replacements = {
176+
'__MERGED_PRS__': open('/tmp/merged_prs.md').read().strip(),
177+
'__REVIEW_PRS__': open('/tmp/review_prs.md').read().strip(),
178+
'__BUG_ISSUES__': open('/tmp/bug_issues.md').read().strip(),
179+
'__OTHER_ISSUES__': open('/tmp/other_issues.md').read().strip(),
180+
}
181+
182+
for key, value in replacements.items():
183+
content = content.replace(key, value)
184+
185+
with open('/tmp/post_body.md', 'w') as f:
186+
f.write(content)
187+
PYEOF
188+
189+
- name: Post to Discourse
190+
id: discourse
191+
run: |
192+
DISPLAY_DATE="${{ steps.dates.outputs.display_date }}"
193+
TITLE="PX4 Dev Call: ${DISPLAY_DATE} (Team sync, and Community Q&A)"
194+
BODY=$(cat /tmp/post_body.md)
195+
196+
RESPONSE=$(curl -s -X POST "${DISCOURSE_URL}/posts.json" \
197+
-H "Api-Key: ${DISCOURSE_API_KEY}" \
198+
-H "Api-Username: ${DISCOURSE_USER}" \
199+
-H "Content-Type: application/json" \
200+
-d "$(jq -n \
201+
--arg title "$TITLE" \
202+
--arg raw "$BODY" \
203+
--argjson category "$CATEGORY_ID" \
204+
'{title: $title, raw: $raw, category: $category}'
205+
)")
206+
207+
TOPIC_ID=$(echo "$RESPONSE" | jq -r '.topic_id // empty')
208+
209+
if [ -z "$TOPIC_ID" ]; then
210+
echo "::error::Failed to create Discourse topic"
211+
echo "$RESPONSE"
212+
exit 1
213+
fi
214+
215+
TOPIC_URL="${DISCOURSE_URL}/t/${TOPIC_ID}"
216+
echo "topic_url=$TOPIC_URL" >> "$GITHUB_OUTPUT"
217+
echo "title=$TITLE" >> "$GITHUB_OUTPUT"
218+
echo "Created: $TOPIC_URL"
219+
220+
# - name: Notify Discord
221+
# if: env.DISCORD_WEBHOOK != ''
222+
# run: |
223+
# TITLE="${{ steps.discourse.outputs.title }}"
224+
# TOPIC_URL="${{ steps.discourse.outputs.topic_url }}"
225+
# MERGED=${{ steps.prs.outputs.merged_count }}
226+
# REVIEW=${{ steps.prs.outputs.review_count }}
227+
# BUGS=${{ steps.issues.outputs.bug_count }}
228+
229+
# curl -s -X POST "$DISCORD_WEBHOOK" \
230+
# -H "Content-Type: application/json" \
231+
# -d "$(jq -n \
232+
# --arg title "$TITLE" \
233+
# --arg url "$TOPIC_URL" \
234+
# --arg desc "Weekly dev call agenda is up. Add your items before Wednesday 17:00 CET." \
235+
# --arg stats "${MERGED} PRs merged | ${REVIEW} awaiting review | ${BUGS} new bugs" \
236+
# '{
237+
# embeds: [{
238+
# title: $title,
239+
# url: $url,
240+
# description: $desc,
241+
# color: 3447003,
242+
# fields: [
243+
# {name: "This Week", value: $stats, inline: false}
244+
# ]
245+
# }]
246+
# }'
247+
# )"

0 commit comments

Comments
 (0)