diff --git a/.github/scripts/bot-gfi-candidate-notification.js b/.github/scripts/bot-gfi-candidate-notification.js new file mode 100644 index 000000000..65b7f4d47 --- /dev/null +++ b/.github/scripts/bot-gfi-candidate-notification.js @@ -0,0 +1,88 @@ +// Script to notify the team when a Good First Issue Candidate is created. + +const marker = ''; +const TEAM_ALIAS = '@hiero-ledger/hiero-sdk-good-first-issue-support'; + + +async function notifyTeam(github, owner, repo, issue, message) { + const dryRun = process.env.DRY_RUN === 'true'; + if (dryRun) { + console.log('Notified team about GFI candidate'); + console.log(`Repo: ${owner}/${repo}`); + console.log(`Issue: #${issue.number} - ${issue.title}`); + console.log(`Message:\n${message}`); + return true; + } + const comment = `${marker} :wave: Hello Team :wave: +${TEAM_ALIAS} + +${message} + +Repository: ${owner}/${repo} +Issue: #${issue.number} - ${issue.title || '(no title)'} + +Best Regards, +Hiero Python SDK team`; + + try { + await github.rest.issues.createComment({ + owner, + repo, + issue_number: issue.number, + body: comment, + }); + console.log(`Notified team about #${issue.number}`); + return true; + } catch (err) { + console.log( + `Failed to notify team about GFI candidate #${issue.number}:`, + err.message || err + ); + return false; + } +} + +module.exports = async ({ github, context }) => { + try { + const { owner, repo } = context.repo; + const { issue, label } = context.payload; + const dryRun = process.env.DRY_RUN === 'true'; + + if (!issue?.number || !label?.name) { + return console.log('Missing issue or label in payload'); + } + + // Only handle Good First Issue Candidate + if (label.name.toLowerCase() !== 'good first issue candidate') { + return; + } + + // Checking dry run + dryRun && console.log('DRY-RUN active'); + + // Prevent duplicate notifications + 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}`); + } + + const message = + 'A new Good First Issue Candidate has been created. Please review it and confirm whether it should be labeled as a Good First Issue.'; + + const success = await notifyTeam(github, owner, repo, issue, message); + + if (success) { + console.log('=== Summary ==='); + console.log(`Repository: ${owner}/${repo}`); + console.log(`Issue Number: ${issue.number}`); + console.log(`Label: ${label.name}`); + } + } catch (err) { + console.log('❌ Error:', err.message); + throw err; + } +}; diff --git a/.github/workflows/bot-gfi-candidate-notification.yaml b/.github/workflows/bot-gfi-candidate-notification.yaml new file mode 100644 index 000000000..072732d6e --- /dev/null +++ b/.github/workflows/bot-gfi-candidate-notification.yaml @@ -0,0 +1,39 @@ +# This workflow notifies the GFI support team when an issue is labeled as GFI Candidate. + +name: Good First Issue Candidate Notification + +on: + issues: + types: + - labeled + +permissions: + issues: write + contents: read + +jobs: + gfi_candidate_notify_team: + runs-on: ubuntu-latest + if: contains(github.event.issue.labels.*.name, 'good first issue candidate') + concurrency: + group: gfi-candidate-${{ github.event.issue.number }} + cancel-in-progress: false + + steps: + - name: Harden the runner + uses: step-security/harden-runner@20cf305ff2072d973412fa9b1e3a4f227bda3c76 + with: + egress-policy: audit + + - name: Checkout repository + uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 #v6.0.1 + + - name: Notify team of GFI candidate + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + DRY_RUN: ${{ github.repository_owner != 'hiero-ledger' }} + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd #v8.0.0 + with: + script: | + const script = require('./.github/scripts/bot-gfi-candidate-notification.js'); + await script({ github, context }); diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e23c1f5e..000a33272 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1. ## [Unreleased] ### Added + +- Added a notification workflow that alerts the support team when an issue is labeled as a Good First Issue Candidate.[(#1296)] - Added comprehensive training documentation for the `Query` class, covering execution flow, payments, retries, and building child queries. (#1238) - Beginner issue documentation and updated GFI and GFIC templates and documentation - Enable auto assignment to good first issues (#1312), archived good first issue support team notification. Changed templates with new assign instruction. @@ -14,10 +16,9 @@ This changelog is based on [Keep a Changelog](https://keepachangelog.com/en/1.1. - Added unit test for 'endpoint.py' to increase coverage. - 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) - Added Hbar object support for TransferTransaction HBAR transfers: - - Methods now accept `Union[int, Hbar]` for amount parameters with immediate normalization to tinybars - - Includes comprehensive unit tests covering various Hbar units (HBAR, MICROBAR, NANOBAR, TINYBAR) and accumulation behavior with mixed `int` and `Hbar` inputs -- 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) +- Methods now accept `Union[int, Hbar]` for amount parameters with immediate normalization to tinybars +- Includes comprehensive unit tests covering various Hbar units (HBAR, MICROBAR, NANOBAR, TINYBAR) and accumulation behavior with mixed `int` and `Hbar` inputs +- 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) - Added a GitHub Actions workflow to validate broken Markdown links in pull requests. - Added method chaining examples to the developer training guide (`docs/sdk_developers/training/coding_token_transactions.md`) (#1194) - Added documentation explaining how to pin GitHub Actions to specific commit SHAs (`docs/sdk_developers/how-to-pin-github-actions.md`)(#1211)