diff --git a/.github/scripts/gfi_notify_team.js b/.github/scripts/gfi_notify_team.js new file mode 100644 index 000000000..80c9e4c3c --- /dev/null +++ b/.github/scripts/gfi_notify_team.js @@ -0,0 +1,73 @@ +// Script to notify the team when a GFI issue is labeled. + +const marker = ''; +const TEAM_ALIAS = '@hiero-ledger/hiero-sdk-good-first-issue-support'; + +async function notifyTeam(github, owner, repo, issue, message, marker) { + const comment = `${marker} :wave: Hello Team :wave: +${TEAM_ALIAS} + +${message} + +Repository: ${owner}/${repo} : Issue: #${issue.number} - ${issue.title || '(no title)'} + +Best Regards, +Python SDK team`; + + try { + await github.rest.issues.createComment({ + owner, + repo, + issue_number: issue.number, + body: comment, + }); + console.log(`Notified team about GFI issue #${issue.number}`); + return true; + } catch (commentErr) { + console.log(`Failed to notify team about GFI issue #${issue.number}:`, commentErr.message || commentErr); + return false; + } +} + +module.exports = async ({ github, context }) => { + try { + const { owner, repo } = context.repo; + const { issue, label } = context.payload; + + if (!issue?.number) return console.log('No issue in payload'); + + const labelName = label?.name; + if (!labelName) return; + + let message = ''; + if (labelName === 'Good First Issue') { + message = 'There is a new GFI in the Python SDK which is ready to be assigned'; + } else if (labelName === 'Good First Issue Candidate') { + message = 'An issue in the Python SDK requires immediate attention to verify if it is a GFI and label it appropriately'; + } else { + return; + } + + // Check for existing comment + const comments = await github.paginate(github.rest.issues.listComments, { + owner, repo, issue_number: issue.number, per_page: 100 + }); + if (comments.some(c => c.body?.includes(marker))) { + return console.log(`Notification already exists for #${issue.number}`); + } + + // Post notification + const success = await notifyTeam(github, owner, repo, issue, message, marker); + + if (success) { + console.log('=== Summary ==='); + console.log(`Repository: ${owner}/${repo}`); + console.log(`Issue Number: ${issue.number}`); + console.log(`Label: ${labelName}`); + console.log(`Message: ${message}`); + } + + } catch (err) { + console.log('❌ Error:', err.message); + } +}; \ No newline at end of file diff --git a/.github/workflows/bot-gfi-notify-team.yml b/.github/workflows/bot-gfi-notify-team.yml new file mode 100644 index 000000000..22f3ae2a1 --- /dev/null +++ b/.github/workflows/bot-gfi-notify-team.yml @@ -0,0 +1,37 @@ +# This workflow notifies the GFI support team when an issue is labeled as a GFI or GFI Candidate. +name: GFI Issue Notification +on: + issues: + types: + - labeled + +permissions: + issues: write + contents: read + +jobs: + gfi_notify_team: + runs-on: ubuntu-latest + if: > + (github.event_name == 'issues' && ( + github.event.label.name == 'Good First Issue' || + github.event.label.name == 'Good First Issue Candidate' + )) + + steps: + - name: Harden the runner + uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 # v2.14.0 + with: + egress-policy: audit + + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1 + + - name: Notify team of GFI issues + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #v8.0.0 + with: + script: | + const script = require('./.github/scripts/gfi_notify_team.js'); + await script({ github, context}); \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a3c78672..613b190ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -44,6 +44,7 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1. - Enhanced `.github/ISSUE_TEMPLATE/01_good_first_issue.yml` with welcoming message and acceptance criteria sections to guide contributors in creating quality GFIs (#1052) - Add workflow to notify team about P0 issues `bot-p0-issues-notify-team.yml` - Added Issue Reminder (no-PR) bot, .github/scripts/issue_reminder_no_pr.sh and .github/workflows/bot-issue-reminder-no-pr.yml to automatically detect assigned issues with no linked pull requests for 7+ days and post a gentle ReminderBot comment.(#951) +- Add a workflow to notify the team when issues are labeled as “good first issues” or identified as candidates for that label: `bot-gfi-notify-team.yml`(#1115) ### Changed - Improved consistency of transaction examples (#1120)