Skip to content

Commit 3c4809a

Browse files
committed
chore: abstract into separate script
Signed-off-by: exploreriii <[email protected]>
1 parent b965bf0 commit 3c4809a

File tree

2 files changed

+88
-74
lines changed

2 files changed

+88
-74
lines changed
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
DRY_RUN="${DRY_RUN:-false}"
5+
6+
ANCHOR_DATE="2025-12-03"
7+
MEETING_LINK="https://zoom-lfx.platform.linuxfoundation.org/meeting/99912667426?password=5b584a0e-1ed7-49d3-b2fc-dc5ddc888338"
8+
CALENDAR_LINK="https://zoom-lfx.platform.linuxfoundation.org/meetings/hiero?view=week"
9+
10+
EXCLUDED_AUTHORS=(
11+
"hiero-sdk-python-maintainers"
12+
"hiero-sdk-python-committers"
13+
)
14+
15+
IS_MEETING_WEEK=$(python3 - <<EOF
16+
from datetime import date
17+
d1 = date.fromisoformat("$ANCHOR_DATE")
18+
d2 = date.today()
19+
print("true" if (d2 - d1).days % 14 == 0 else "false")
20+
EOF
21+
)
22+
23+
if [ "$IS_MEETING_WEEK" = "false" ]; then
24+
echo "Not a fortnightly meeting week. Exiting."
25+
exit 0
26+
fi
27+
28+
REPO="${GITHUB_REPOSITORY:-$(gh repo view --json nameWithOwner -q .nameWithOwner)}"
29+
30+
PR_DATA=$(gh pr list --repo "$REPO" --state open --json number,author,createdAt)
31+
32+
if [ -z "$PR_DATA" ] || [ "$PR_DATA" = "[]" ]; then
33+
echo "No open PRs found."
34+
exit 0
35+
fi
36+
37+
COMMENT_BODY=$(cat <<EOF
38+
Hello, this is the OfficeHourBot.
39+
40+
This is a reminder that the Hiero Python SDK Office Hours are scheduled in approximately 4 hours (14:00 UTC).
41+
42+
This session provides an opportunity to ask questions regarding this Pull Request.
43+
44+
Details:
45+
- Time: 14:00 UTC
46+
- Join Link: [Zoom Meeting]($MEETING_LINK)
47+
48+
Disclaimer: This is an automated reminder. Please verify the schedule [here]($CALENDAR_LINK) for any changes.
49+
50+
From,
51+
The Python SDK Team
52+
53+
EOF
54+
)
55+
56+
echo "$PR_DATA" |
57+
jq -r '
58+
group_by(.author.login)
59+
| .[]
60+
| sort_by(.createdAt)
61+
| reverse
62+
| .[0]
63+
| "\(.number) \(.author.login)"
64+
' |
65+
while read PR_NUM AUTHOR; do
66+
for EXCLUDED in "${EXCLUDED_AUTHORS[@]}"; do
67+
if [ "$AUTHOR" = "$EXCLUDED" ]; then
68+
echo "Skipping PR #$PR_NUM by excluded author @$AUTHOR"
69+
continue 2
70+
fi
71+
done
72+
73+
ALREADY_COMMENTED=$(gh pr view "$PR_NUM" --repo "$REPO" --json comments --jq '.comments[].body' | grep -F "Office Hour Bot" || true)
74+
75+
if [ -n "$ALREADY_COMMENTED" ]; then
76+
echo "PR #$PR_NUM already notified. Skipping."
77+
continue
78+
fi
79+
80+
if [ "$DRY_RUN" = "true" ]; then
81+
echo "[DRY RUN] Would comment on PR #$PR_NUM"
82+
else
83+
gh pr comment "$PR_NUM" --repo "$REPO" --body "$COMMENT_BODY"
84+
echo "Reminder posted to PR #$PR_NUM"
85+
fi
86+
done

.github/workflows/bot-office-hours.yml

Lines changed: 2 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -22,78 +22,6 @@ jobs:
2222
- name: Check Schedule and Notify
2323
env:
2424
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
25+
DRY_RUN: "true"
2526
run: |
26-
set -euo pipefail
27-
ANCHOR_DATE="2025-12-03"
28-
MEETING_LINK="https://zoom-lfx.platform.linuxfoundation.org/meeting/99912667426?password=5b584a0e-1ed7-49d3-b2fc-dc5ddc888338"
29-
CALENDAR_LINK="https://zoom-lfx.platform.linuxfoundation.org/meetings/hiero?view=week"
30-
31-
EXCLUDED_AUTHORS=(
32-
"hiero-sdk-python-maintainers"
33-
"hiero-sdk-python-committers"
34-
)
35-
36-
IS_MEETING_WEEK=$(python3 -c "from datetime import date; import os; d1=date.fromisoformat('$ANCHOR_DATE'); d2=date.today(); print('true' if (d2-d1).days % 14 == 0 else 'false')")
37-
38-
if [ "$IS_MEETING_WEEK" = "false" ]; then
39-
echo "Not a fortnightly meeting week. Skipping execution."
40-
exit 0
41-
fi
42-
43-
echo "Meeting week detected. Proceeding to notify open PRs."
44-
45-
REPO="${{ github.repository }}"
46-
PR_DATA=$(gh pr list --repo $REPO --state open --json number,author,createdAt)
47-
48-
if [ -z "$PR_DATA" ] || [ "$PR_DATA" = "[]" ]; then
49-
echo "No open PRs found."
50-
exit 0
51-
fi
52-
53-
COMMENT_BODY=$(cat <<EOF
54-
Hello, this is the Office Hour Bot.
55-
56-
This is a reminder that the Hiero Python SDK Office Hours are scheduled in approximately 4 hours (14:00 UTC).
57-
58-
This session provides an opportunity to ask questions regarding this Pull Request or receive assistance from a maintainer.
59-
60-
Details:
61-
- Time: 14:00 UTC
62-
- Join Link: [Zoom Meeting]($MEETING_LINK)
63-
64-
Disclaimer: This is an automated reminder. Please verify the schedule [here]($CALENDAR_LINK) to be notified of any changes.
65-
EOF
66-
)
67-
68-
echo "$PR_DATA" |
69-
jq -r '
70-
group_by(.author.login)
71-
| .[]
72-
| sort_by(.createdAt)
73-
| reverse
74-
| .[0]
75-
| "\(.number) \(.author.login)"
76-
' |
77-
while read PR_NUM AUTHOR; do
78-
SKIP=false
79-
for EXCLUDED in "${EXCLUDED_AUTHORS[@]}"; do
80-
if [ "$AUTHOR" = "$EXCLUDED" ]; then
81-
SKIP=true
82-
break
83-
fi
84-
done
85-
86-
if [ "$SKIP" = "true" ]; then
87-
echo "Skipping PR #$PR_NUM by excluded author @$AUTHOR"
88-
continue
89-
fi
90-
91-
ALREADY_COMMENTED=$(gh pr view $PR_NUM --repo $REPO --json comments --jq '.comments[].body' | grep -F "Office Hour Bot" || true)
92-
93-
if [ -z "$ALREADY_COMMENTED" ]; then
94-
gh pr comment $PR_NUM --repo $REPO --body "$COMMENT_BODY"
95-
echo "Reminder posted to PR #$PR_NUM"
96-
else
97-
echo "PR #$PR_NUM already notified. Skipping."
98-
fi
99-
done
27+
bash ./scripts/office_hour_reminder.sh

0 commit comments

Comments
 (0)