diff --git a/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js b/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js index fdc16161db62c..5a5bf40978a1f 100644 --- a/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js +++ b/packages/project-management-automation/lib/tasks/first-time-contributor-label/index.js @@ -46,6 +46,22 @@ async function firstTimeContributorLabel( payload, octokit ) { issue_number: payload.pull_request.number, labels: [ 'First-time Contributor' ], } ); + + /** + * Adds a welcome comment to the first time PR + */ + + await octokit.issues.createComment( { + owner, + repo, + issue_number: payload.pull_request.number, + body: + ':wave: Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @' + + author + + "!. In case you missed it, we'd love to have you join us in our [Slack community](https://make.wordpress.org/chat/)," + + 'where we hold [regularly weekly meetings](https://make.wordpress.org/core/tag/core-editor-summary/) open to anyone to coordinate with each other.\n\n' + + 'If you want to learn more about WordPress development in general, check out the [Core Handbook](https://make.wordpress.org/core/handbook/) full of helpful information.', + } ); } module.exports = firstTimeContributorLabel; diff --git a/packages/project-management-automation/lib/tasks/first-time-contributor-label/test/index.js b/packages/project-management-automation/lib/tasks/first-time-contributor-label/test/index.js index 83e356bb7bca8..b1710ab585325 100644 --- a/packages/project-management-automation/lib/tasks/first-time-contributor-label/test/index.js +++ b/packages/project-management-automation/lib/tasks/first-time-contributor-label/test/index.js @@ -32,6 +32,7 @@ describe( 'firstTimeContributorLabel', () => { }, issues: { addLabels: jest.fn(), + createComment: jest.fn(), }, }; @@ -43,6 +44,7 @@ describe( 'firstTimeContributorLabel', () => { author: 'ghost', } ); expect( octokit.issues.addLabels ).not.toHaveBeenCalled(); + expect( octokit.issues.createComment ).not.toHaveBeenCalled(); } ); it( 'adds the First Time Contributor label if the user has no commits', async () => { @@ -56,9 +58,16 @@ describe( 'firstTimeContributorLabel', () => { }, issues: { addLabels: jest.fn(), + createComment: jest.fn(), }, }; + const expectedComment = + ':wave: Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @ghost' + + "!. In case you missed it, we'd love to have you join us in our [Slack community](https://make.wordpress.org/chat/)," + + 'where we hold [regularly weekly meetings](https://make.wordpress.org/core/tag/core-editor-summary/) open to anyone to coordinate with each other.\n\n' + + 'If you want to learn more about WordPress development in general, check out the [Core Handbook](https://make.wordpress.org/core/handbook/) full of helpful information.'; + await firstTimeContributorLabel( payload, octokit ); expect( octokit.repos.listCommits ).toHaveBeenCalledWith( { @@ -72,5 +81,11 @@ describe( 'firstTimeContributorLabel', () => { issue_number: 123, labels: [ 'First-time Contributor' ], } ); + expect( octokit.issues.createComment ).toHaveBeenCalledWith( { + owner: 'WordPress', + repo: 'gutenberg', + issue_number: 123, + body: expectedComment, + } ); } ); } );