Skip to content

Commit cc2bec0

Browse files
authored
feat: add notification workflow for Good First Issue candidates [(#1296)] (#1342)
Signed-off-by: Parv <[email protected]> Signed-off-by: Parv Ninama <[email protected]>
1 parent edf4d5a commit cc2bec0

File tree

3 files changed

+132
-4
lines changed

3 files changed

+132
-4
lines changed
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Script to notify the team when a Good First Issue Candidate is created.
2+
3+
const marker = '<!-- GFI Candidate Notification -->';
4+
const TEAM_ALIAS = '@hiero-ledger/hiero-sdk-good-first-issue-support';
5+
6+
7+
async function notifyTeam(github, owner, repo, issue, message) {
8+
const dryRun = process.env.DRY_RUN === 'true';
9+
if (dryRun) {
10+
console.log('Notified team about GFI candidate');
11+
console.log(`Repo: ${owner}/${repo}`);
12+
console.log(`Issue: #${issue.number} - ${issue.title}`);
13+
console.log(`Message:\n${message}`);
14+
return true;
15+
}
16+
const comment = `${marker} :wave: Hello Team :wave:
17+
${TEAM_ALIAS}
18+
19+
${message}
20+
21+
Repository: ${owner}/${repo}
22+
Issue: #${issue.number} - ${issue.title || '(no title)'}
23+
24+
Best Regards,
25+
Hiero Python SDK team`;
26+
27+
try {
28+
await github.rest.issues.createComment({
29+
owner,
30+
repo,
31+
issue_number: issue.number,
32+
body: comment,
33+
});
34+
console.log(`Notified team about #${issue.number}`);
35+
return true;
36+
} catch (err) {
37+
console.log(
38+
`Failed to notify team about GFI candidate #${issue.number}:`,
39+
err.message || err
40+
);
41+
return false;
42+
}
43+
}
44+
45+
module.exports = async ({ github, context }) => {
46+
try {
47+
const { owner, repo } = context.repo;
48+
const { issue, label } = context.payload;
49+
const dryRun = process.env.DRY_RUN === 'true';
50+
51+
if (!issue?.number || !label?.name) {
52+
return console.log('Missing issue or label in payload');
53+
}
54+
55+
// Only handle Good First Issue Candidate
56+
if (label.name.toLowerCase() !== 'good first issue candidate') {
57+
return;
58+
}
59+
60+
// Checking dry run
61+
dryRun && console.log('DRY-RUN active');
62+
63+
// Prevent duplicate notifications
64+
const comments = await github.paginate(
65+
github.rest.issues.listComments,
66+
{ owner, repo, issue_number: issue.number, per_page: 100 }
67+
);
68+
69+
if (comments.some(c => c.body?.includes(marker))) {
70+
return console.log(`Notification already exists for #${issue.number}`);
71+
}
72+
73+
const message =
74+
'A new Good First Issue Candidate has been created. Please review it and confirm whether it should be labeled as a Good First Issue.';
75+
76+
const success = await notifyTeam(github, owner, repo, issue, message);
77+
78+
if (success) {
79+
console.log('=== Summary ===');
80+
console.log(`Repository: ${owner}/${repo}`);
81+
console.log(`Issue Number: ${issue.number}`);
82+
console.log(`Label: ${label.name}`);
83+
}
84+
} catch (err) {
85+
console.log('❌ Error:', err.message);
86+
throw err;
87+
}
88+
};
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# This workflow notifies the GFI support team when an issue is labeled as GFI Candidate.
2+
3+
name: Good First Issue Candidate Notification
4+
5+
on:
6+
issues:
7+
types:
8+
- labeled
9+
10+
permissions:
11+
issues: write
12+
contents: read
13+
14+
jobs:
15+
gfi_candidate_notify_team:
16+
runs-on: ubuntu-latest
17+
if: contains(github.event.issue.labels.*.name, 'good first issue candidate')
18+
concurrency:
19+
group: gfi-candidate-${{ github.event.issue.number }}
20+
cancel-in-progress: false
21+
22+
steps:
23+
- name: Harden the runner
24+
uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76
25+
with:
26+
egress-policy: audit
27+
28+
- name: Checkout repository
29+
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1
30+
31+
- name: Notify team of GFI candidate
32+
env:
33+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34+
DRY_RUN: ${{ github.repository_owner != 'hiero-ledger' }}
35+
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #v8.0.0
36+
with:
37+
script: |
38+
const script = require('./.github/scripts/bot-gfi-candidate-notification.js');
39+
await script({ github, context });

CHANGELOG.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,18 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.
77
## [Unreleased]
88

99
### Added
10+
11+
- Added a notification workflow that alerts the support team when an issue is labeled as a Good First Issue Candidate.[(#1296)]
1012
- Added comprehensive training documentation for the `Query` class, covering execution flow, payments, retries, and building child queries. (#1238)
1113
- Beginner issue documentation and updated GFI and GFIC templates and documentation
1214
- Enable auto assignment to good first issues (#1312), archived good first issue support team notification. Changed templates with new assign instruction.
1315
- Intermediate issue documentation
1416
- Added unit test for 'endpoint.py' to increase coverage.
1517
- Automated assignment guard for `advanced` issues; requires completion of at least one `good first issue` and one `intermediate` issue before assignment (exempts maintainers, committers, and triage members). (#1142)
1618
- Added Hbar object support for TransferTransaction HBAR transfers:
17-
- Methods now accept `Union[int, Hbar]` for amount parameters with immediate normalization to tinybars
18-
- Includes comprehensive unit tests covering various Hbar units (HBAR, MICROBAR, NANOBAR, TINYBAR) and accumulation behavior with mixed `int` and `Hbar` inputs
19-
- Added a module-level docstring to the HBAR allowance approval example to clarify
20-
delegated spending behavior and key concepts. [#1202](https://github.com/hiero-ledger/hiero-sdk-python/issues/1202)
19+
- Methods now accept `Union[int, Hbar]` for amount parameters with immediate normalization to tinybars
20+
- Includes comprehensive unit tests covering various Hbar units (HBAR, MICROBAR, NANOBAR, TINYBAR) and accumulation behavior with mixed `int` and `Hbar` inputs
21+
- Added a module-level docstring to the HBAR allowance approval example to clarify delegated spending behavior and key concepts. [#1202](https://github.com/hiero-ledger/hiero-sdk-python/issues/1202)
2122
- Added a GitHub Actions workflow to validate broken Markdown links in pull requests.
2223
- Added method chaining examples to the developer training guide (`docs/sdk_developers/training/coding_token_transactions.md`) (#1194)
2324
- Added documentation explaining how to pin GitHub Actions to specific commit SHAs (`docs/sdk_developers/how-to-pin-github-actions.md`)(#1211)

0 commit comments

Comments
 (0)