-
Notifications
You must be signed in to change notification settings - Fork 152
feat: add notification workflow for Good First Issue candidates [(#1296)] #1342
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
62e4913
feat: add notification workflow for Good First Issue candidates
parvninama fdfa24d
feat: add dry-run support to GFI candidate notification bot
parvninama 1150bdc
feat:Add concurrency group for deterministic execution.
parvninama 85eb5ba
chore:add comments for clarity
parvninama b35f9c1
fix: prevent dry-run errors in GFI candidate notification
parvninama f03cfbf
Merge branch 'main' into feat/gfi-candidate
parvninama b84a721
Merge branch 'main' into feat/gfi-candidate
parvninama cdf19b7
Merge branch 'main' into feat/gfi-candidate
parvninama File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,88 @@ | ||
| // Script to notify the team when a Good First Issue Candidate is created. | ||
|
|
||
| const marker = '<!-- GFI Candidate Notification -->'; | ||
| 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 = | ||
exploreriii marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| '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; | ||
| } | ||
| }; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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') | ||
exploreriii marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| 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 }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.