From 5ed823397103ae4d89eafb16e77e40d312e2b0ce Mon Sep 17 00:00:00 2001 From: alphaBEE <61616007+ankitsmt211@users.noreply.github.com> Date: Sun, 20 Oct 2024 00:16:29 +0530 Subject: [PATCH 1/5] github action for merged PR to ask user for their username if they're a member --- .github/workflows/discord-member.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .github/workflows/discord-member.yml diff --git a/.github/workflows/discord-member.yml b/.github/workflows/discord-member.yml new file mode 100644 index 0000000000..0f25a71d16 --- /dev/null +++ b/.github/workflows/discord-member.yml @@ -0,0 +1,26 @@ +name: Comment When PR Merged +on: + pull_request: + types: + - closed + branches: + - 'develop/**' + + +jobs: + if_merged: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v7 + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `Congratulations on your first contribution! We're excited to have you on board. Your work will be included in the next release, so stay tuned! + Are you a Together-Java member on Discord? If so, please share your username here. If not, that’s perfectly fine! If you change your mind, here's the link: discord_link. + Why do we need your username? We’d like to give you a shoutout to show our gratitude!` + }) From b6d6193a2b0daff01c501ee543b3f2ac896d34bd Mon Sep 17 00:00:00 2001 From: alphaBEE <61616007+ankitsmt211@users.noreply.github.com> Date: Sun, 20 Oct 2024 00:23:00 +0530 Subject: [PATCH 2/5] improve logic for workflow to only check first time contributors --- .github/workflows/discord-member.yml | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/.github/workflows/discord-member.yml b/.github/workflows/discord-member.yml index 0f25a71d16..37f7a12cdf 100644 --- a/.github/workflows/discord-member.yml +++ b/.github/workflows/discord-member.yml @@ -16,7 +16,24 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} script: | - github.rest.issues.createComment({ + const creator = context.payload.sender.login + const opts = github.rest.issues.listForRepo.endpoint.merge({ + ...context.issue, + creator, + state: 'all' + }) + const issues = await github.paginate(opts) + + for (const issue of issues) { + if (issue.number === context.issue.number) { + continue + } + + if (issue.pull_request) { + return + } + } + await github.rest.issues.createComment({ issue_number: context.issue.number, owner: context.repo.owner, repo: context.repo.repo, From ee6f418ac93228641a0a783f66e03f118707e5f4 Mon Sep 17 00:00:00 2001 From: alphaBEE <61616007+ankitsmt211@users.noreply.github.com> Date: Sun, 20 Oct 2024 00:45:40 +0530 Subject: [PATCH 3/5] add server invite via github secrets --- .github/workflows/discord-member.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/discord-member.yml b/.github/workflows/discord-member.yml index 37f7a12cdf..78b1c1ef8a 100644 --- a/.github/workflows/discord-member.yml +++ b/.github/workflows/discord-member.yml @@ -38,6 +38,6 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, body: `Congratulations on your first contribution! We're excited to have you on board. Your work will be included in the next release, so stay tuned! - Are you a Together-Java member on Discord? If so, please share your username here. If not, that’s perfectly fine! If you change your mind, here's the link: discord_link. + Are you a Together-Java member on Discord? If so, please share your username here. If not, that’s perfectly fine! If you change your mind, here's the link: ${{secrets.SERVER_INVITE}}. Why do we need your username? We’d like to give you a shoutout to show our gratitude!` }) From 00c9d3b486ef13ebd047d43049465a1db53c6fb2 Mon Sep 17 00:00:00 2001 From: alphaBEE <61616007+ankitsmt211@users.noreply.github.com> Date: Sun, 20 Oct 2024 00:55:56 +0530 Subject: [PATCH 4/5] use variables instead of secret for invite link --- .github/workflows/discord-member.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/discord-member.yml b/.github/workflows/discord-member.yml index 78b1c1ef8a..fb74c3bde8 100644 --- a/.github/workflows/discord-member.yml +++ b/.github/workflows/discord-member.yml @@ -38,6 +38,6 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, body: `Congratulations on your first contribution! We're excited to have you on board. Your work will be included in the next release, so stay tuned! - Are you a Together-Java member on Discord? If so, please share your username here. If not, that’s perfectly fine! If you change your mind, here's the link: ${{secrets.SERVER_INVITE}}. + Are you a Together-Java member on Discord? If so, please share your username here. If not, that’s perfectly fine! If you change your mind, here's the link: ${{vars.SERVER_INVITE}}. Why do we need your username? We’d like to give you a shoutout to show our gratitude!` }) From 26a9381accf01c9bfc77eff56215d2991051766c Mon Sep 17 00:00:00 2001 From: alphaBEE <61616007+ankitsmt211@users.noreply.github.com> Date: Sun, 20 Oct 2024 01:01:41 +0530 Subject: [PATCH 5/5] fix develop branch pattern --- .github/workflows/discord-member.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/discord-member.yml b/.github/workflows/discord-member.yml index fb74c3bde8..8296e7467e 100644 --- a/.github/workflows/discord-member.yml +++ b/.github/workflows/discord-member.yml @@ -4,7 +4,7 @@ on: types: - closed branches: - - 'develop/**' + - develop jobs: