Skip to content

Commit 0caa232

Browse files
authored
feat: exclude maintainers and committers from office hours notifications (hiero-ledger#1171)
Signed-off-by: exploreriii <[email protected]>
1 parent 6250885 commit 0caa232

File tree

3 files changed

+129
-52
lines changed

3 files changed

+129
-52
lines changed
Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
DRY_RUN="${DRY_RUN:-true}"
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+
CANCELLED_DATES=(
11+
"2025-12-31"
12+
)
13+
14+
EXCLUDED_AUTHORS=(
15+
"rbair23"
16+
"nadineloepfe"
17+
"exploreriii"
18+
"manishdait"
19+
"Dosik13"
20+
"hendrikebbers"
21+
)
22+
23+
if [ "$DRY_RUN" = "true" ]; then
24+
echo "=== DRY RUN MODE ENABLED ==="
25+
echo "No comments will be posted."
26+
fi
27+
28+
TODAY=$(date -u +"%Y-%m-%d")
29+
for CANCELLED in "${CANCELLED_DATES[@]}"; do
30+
if [ "$TODAY" = "$CANCELLED" ]; then
31+
echo "Office Hours cancelled on $TODAY. Exiting."
32+
exit 0
33+
fi
34+
done
35+
36+
37+
IS_MEETING_WEEK=$(python3 - <<EOF
38+
from datetime import datetime, date, timezone
39+
d1 = date.fromisoformat("$ANCHOR_DATE")
40+
d2 = datetime.now(timezone.utc).date()
41+
print("true" if (d2 - d1).days % 14 == 0 else "false")
42+
EOF
43+
)
44+
45+
if [ "$IS_MEETING_WEEK" = "false" ]; then
46+
echo "Not a fortnightly meeting week. Exiting."
47+
exit 0
48+
fi
49+
50+
if [ -z "${GITHUB_REPOSITORY:-}" ]; then
51+
echo "ERROR: GITHUB_REPOSITORY is not set."
52+
echo "Set it explicitly, e.g.:"
53+
echo " export GITHUB_REPOSITORY=owner/repo"
54+
exit 1
55+
fi
56+
57+
REPO="$GITHUB_REPOSITORY"
58+
59+
PR_DATA=$(gh pr list --repo "$REPO" --state open --json number,author,createdAt)
60+
61+
if [ -z "$PR_DATA" ] || [ "$PR_DATA" = "[]" ]; then
62+
echo "No open PRs found."
63+
exit 0
64+
fi
65+
66+
COMMENT_BODY=$(cat <<EOF
67+
Hello, this is the OfficeHourBot.
68+
69+
This is a reminder that the Hiero Python SDK Office Hours are scheduled in approximately 4 hours (14:00 UTC).
70+
71+
This session provides an opportunity to ask questions regarding this Pull Request.
72+
73+
Details:
74+
- Time: 14:00 UTC
75+
- Join Link: [Zoom Meeting]($MEETING_LINK)
76+
77+
Disclaimer: This is an automated reminder. Please verify the schedule [here]($CALENDAR_LINK) for any changes.
78+
79+
From,
80+
The Python SDK Team
81+
82+
EOF
83+
)
84+
85+
echo "$PR_DATA" |
86+
jq -r '
87+
group_by(.author.login)
88+
| .[]
89+
| sort_by(.createdAt)
90+
| reverse
91+
| .[0]
92+
| "\(.number) \(.author.login)"
93+
' |
94+
while read PR_NUM AUTHOR; do
95+
for EXCLUDED in "${EXCLUDED_AUTHORS[@]}"; do
96+
if [ "$AUTHOR" = "$EXCLUDED" ]; then
97+
echo "Skipping PR #$PR_NUM by excluded author @$AUTHOR"
98+
continue 2
99+
fi
100+
done
101+
102+
ALREADY_COMMENTED=$(gh pr view "$PR_NUM" --repo "$REPO" --json comments --jq '.comments[].body' | grep -F "OfficeHourBot" || true)
103+
104+
if [ -n "$ALREADY_COMMENTED" ]; then
105+
echo "PR #$PR_NUM already notified. Skipping."
106+
continue
107+
fi
108+
109+
if [ "$DRY_RUN" = "true" ]; then
110+
echo "----------------------------------------"
111+
echo "[DRY RUN] Would comment on PR #$PR_NUM"
112+
echo "[DRY RUN] Author: @$AUTHOR"
113+
echo "[DRY RUN] Comment body:"
114+
echo "----------------------------------------"
115+
echo "$COMMENT_BODY"
116+
echo "----------------------------------------"
117+
else
118+
gh pr comment "$PR_NUM" --repo "$REPO" --body "$COMMENT_BODY"
119+
echo "Reminder posted to PR #$PR_NUM"
120+
fi
121+
done
Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
name: PythonBot - Office Hour Reminder
22

33
on:
4-
# push:
54
schedule:
6-
- cron: '0 10 * * 3'
7-
workflow_dispatch:
5+
- cron: "0 10 * * 3"
86

97
permissions:
108
contents: read
@@ -15,59 +13,16 @@ jobs:
1513
runs-on: ubuntu-latest
1614
steps:
1715
- name: Harden the runner
18-
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76
16+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 #2.14.0
1917
with:
2018
egress-policy: audit
2119

20+
- name: Checkout repository
21+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1
22+
2223
- name: Check Schedule and Notify
2324
env:
2425
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
DRY_RUN: "false" # will post
2527
run: |
26-
ANCHOR_DATE="2025-12-03"
27-
MEETING_LINK="https://zoom-lfx.platform.linuxfoundation.org/meeting/99912667426?password=5b584a0e-1ed7-49d3-b2fc-dc5ddc888338"
28-
CALENDAR_LINK="https://zoom-lfx.platform.linuxfoundation.org/meetings/hiero?view=week"
29-
30-
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')")
31-
32-
if [ "$IS_MEETING_WEEK" = "false" ]; then
33-
echo "Not a fortnightly meeting week. Skipping execution."
34-
exit 0
35-
fi
36-
37-
echo "Meeting week detected. Proceeding to notify open PRs."
38-
39-
REPO="${{ github.repository }}"
40-
PR_DATA=$(gh pr list --repo $REPO --state open --json number,author,createdAt)
41-
42-
if [ -z "$PR_DATA" ] || [ "$PR_DATA" = "[]" ]; then
43-
echo "No open PRs found."
44-
exit 0
45-
fi
46-
47-
COMMENT_BODY=$(cat <<EOF
48-
Hello, this is the Office Hour Bot.
49-
50-
This is a reminder that the Hiero Python SDK Office Hours are scheduled in approximately 4 hours (14:00 UTC).
51-
52-
This session provides an opportunity to ask questions regarding this Pull Request or receive assistance from a maintainer.
53-
54-
Details:
55-
- Time: 14:00 UTC
56-
- Join Link: [Zoom Meeting]($MEETING_LINK)
57-
58-
Disclaimer: This is an automated reminder. Please verify the schedule [here]($CALENDAR_LINK) to be notified of any changes.
59-
EOF
60-
)
61-
62-
echo "$PR_DATA" | jq -r 'group_by(.author.login) | .[] | sort_by(.createdAt) | reverse | .[0] | .number' | while read PR_NUM; do
63-
echo "Processing most recent PR #$PR_NUM for user"
64-
65-
ALREADY_COMMENTED=$(gh pr view $PR_NUM --repo $REPO --json comments --jq '.comments[].body' | grep -F "Office Hour Bot" || true)
66-
67-
if [ -z "$ALREADY_COMMENTED" ]; then
68-
gh pr comment $PR_NUM --repo $REPO --body "$COMMENT_BODY"
69-
echo "Reminder posted to PR #$PR_NUM"
70-
else
71-
echo "PR #$PR_NUM already notified. Skipping."
72-
fi
73-
done
28+
bash .github/scripts/bot-office-hours.sh

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
8080
- Improved docstring for `account_allowance_approve_transaction_nft.py` with purpose, key concepts and required vs optional steps.
8181
- Updated Codecov coverage thresholds in 'codecov.yml' to require 90% of project coverage and 92% of patch coverage (#1157)
8282
- Reduce office-hours reminder spam by posting only on each user's most recent open PR, grouping by author and sorting by creation time (#1121)
83+
- Reduce office-hours reminder spam by never posting on PRs of maintainers and committers
8384
- Pylint cleanup for token_airdrop_transaction_cancel.py (#1081) [@tiya-15](https://github.com/tiya-15)
8485
- Move `account_allowance_delete_transaction_hbar.py` from `examples/` to `examples/account/` for better organization (#1003)
8586
- Improved consistency of transaction examples (#1120)

0 commit comments

Comments
 (0)