From 651fe69ad2a250c9e78e94dce1fb739dff7cd812 Mon Sep 17 00:00:00 2001 From: Mintu Date: Thu, 4 Jan 2024 13:04:07 +0530 Subject: [PATCH 01/30] a test pr --- test.txt | 1 + 1 file changed, 1 insertion(+) create mode 100644 test.txt diff --git a/test.txt b/test.txt new file mode 100644 index 00000000..8909c17a --- /dev/null +++ b/test.txt @@ -0,0 +1 @@ +hii \ No newline at end of file From bfe89d6212001630775c73921e1a3e8a48ae3007 Mon Sep 17 00:00:00 2001 From: Mintu Date: Thu, 4 Jan 2024 13:17:35 +0530 Subject: [PATCH 02/30] modified the test --- .../automerge-for-humans-merging.yml | 46 +------------------ index.js | 42 +++++++++++++++++ 2 files changed, 43 insertions(+), 45 deletions(-) create mode 100644 index.js diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index d32e6b13..8b72957d 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -33,51 +33,7 @@ jobs: run: npm install node-fetch @octokit/core @octokit/plugin-paginate-rest - name: Merge PR with Co-Authors - - run: | - run: | - const fetch = require('node-fetch'); - const { Octokit } = require('@octokit/rest'); - const { paginateRest } = require('@octokit/plugin-paginate-rest'); - - const token = process.env.GITHUB_TOKEN; - const prNumber = process.env.PR_NUMBER; - const prTitle = process.env.PR_TITLE; - const repostory = process.env.GITHUB_REPOSITORY; - - async function getCoAuthors() { - try { - const octokit = new Octokit({ auth: token }); - const commitsResponse = await octokit.paginate("GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", { - owner: "asyncapi", - repo: repostory, - pull_number: prNumber, - per_page: 100, - }); - - const coAuthors = commitsResponse - .map(commit => ({ - name: commit.commit.author.name, - email: commit.commit.author.email, - login: commit.author.login, - })) - .filter(author => author.login !== 'main_author_login') // Replace 'main_author_login' with the main author's login - .reduce((uniqueAuthors, author) => { - if (!uniqueAuthors.some(a => a.email === author.email)) { - uniqueAuthors.push(author); - } - return uniqueAuthors; - }, []) - .map(author => `Co-authored-by: ${author.name} <${author.email}>`) - .join('\n'); - - return coAuthors; - } catch (error) { - console.error('Error fetching commits:', error); - return null; - } - } - + run: node index.js - name: Automerge PR uses: pascalgn/automerge-action@22948e0bc22f0aa673800da838595a3e7347e584 #v0.15.6 https://github.com/pascalgn/automerge-action/releases/tag/v0.15.6 env: diff --git a/index.js b/index.js new file mode 100644 index 00000000..3b16ab04 --- /dev/null +++ b/index.js @@ -0,0 +1,42 @@ +// const fetch = require('node-fetch'); +// const { Octokit } = require('@octokit/rest'); +// const { paginateRest } = require('@octokit/plugin-paginate-rest'); +import { Octokit } from '@octokit/rest'; +import { paginateRest } from '@octokit/plugin-paginate-rest'; + +const token = process.env.GITHUB_TOKEN; +const prNumber = process.env.PR_NUMBER; +const repository = process.env.GITHUB_REPOSITORY; + +async function getCoAuthors() { + try { + const octokit = new Octokit({ auth: token }); + const commitsResponse = await octokit.paginate("GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", { + owner: "asyncapi", + repo: repository, + pull_number: prNumber, + per_page: 100, + }); + + const authors = commitsResponse + .map(data => ({ + name: data.commit.author.name, + email: data.commit.author.email, + login: data.commit.author.login, + })) + .filter(author => author.login !== 'PR_sender_login') + .reduce((uniqueAuthors, author) => { + if (!uniqueAuthors.some(a => a.email === author.email)) { + uniqueAuthors.push(author); + } + return uniqueAuthors; + }, []) + .map(author => `Co-authored-by: ${author.name} <${author.email}>`) + .join('\n'); + consoler.log(authors); + return authors; + } catch (error) { + console.error('Error fetching commits:', error); + return null; + } +} \ No newline at end of file From 757309d47f4268b35cee9cf548d0f1c2a1d6a5e5 Mon Sep 17 00:00:00 2001 From: Mintu Date: Thu, 4 Jan 2024 13:18:19 +0530 Subject: [PATCH 03/30] added another test --- test.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test.txt b/test.txt index 8909c17a..c8d311e7 100644 --- a/test.txt +++ b/test.txt @@ -1 +1,2 @@ -hii \ No newline at end of file +hii +hello \ No newline at end of file From 595ee945bff8cd0fe369630d93925ff83a240440 Mon Sep 17 00:00:00 2001 From: Mintu Date: Thu, 4 Jan 2024 13:23:24 +0530 Subject: [PATCH 04/30] added the mjs --- .github/workflows/automerge-for-humans-merging.yml | 2 +- index.js => index.mjs | 0 2 files changed, 1 insertion(+), 1 deletion(-) rename index.js => index.mjs (100%) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 8b72957d..4e266c5e 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -33,7 +33,7 @@ jobs: run: npm install node-fetch @octokit/core @octokit/plugin-paginate-rest - name: Merge PR with Co-Authors - run: node index.js + run: node index.mjs - name: Automerge PR uses: pascalgn/automerge-action@22948e0bc22f0aa673800da838595a3e7347e584 #v0.15.6 https://github.com/pascalgn/automerge-action/releases/tag/v0.15.6 env: diff --git a/index.js b/index.mjs similarity index 100% rename from index.js rename to index.mjs From 62d98d9b8f5fa5f697d2a2a019a69ee42b0f74a6 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 12:30:43 +0530 Subject: [PATCH 05/30] hii --- .../automerge-for-humans-merging.yml | 57 +++++++++++++++++-- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 4e266c5e..5a9c2aaf 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -30,10 +30,57 @@ jobs: node-version: '18' - name: Install dependencies - run: npm install node-fetch @octokit/core @octokit/plugin-paginate-rest + run: npm install + working-directory: ./.github/workflows/scripts/mailchimp + - name: Get list of authors + uses: actions/github-script@v5 + id: authors + with: + GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" + PR_NUMBER: ${{ github.event.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + GITHUB_REPOSITORY: ${{ github.repository }} + script: | + const { Octokit } = require('@octokit/rest'); + const { paginateRest } = require('@octokit/plugin-paginate-rest'); + + const token = process.env.GITHUB_TOKEN; + const prNumber = process.env.PR_NUMBER; + const repository = process.env.GITHUB_REPOSITORY; + + async function getCoAuthors() { + try { + const octokit = new Octokit({ auth: token }); + const commitsResponse = await octokit.paginate("GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", { + owner: "asyncapi", + repo: repository, + pull_number: prNumber, + per_page: 100, + }); + + const authors = commitsResponse + .map(data => ({ + name: data.commit.author.name, + email: data.commit.author.email, + login: data.commit.author.login, + })) + .filter(author => author.login !== 'PR_sender_login') + .reduce((uniqueAuthors, author) => { + if (!uniqueAuthors.some(a => a.email === author.email)) { + uniqueAuthors.push(author); + } + return uniqueAuthors; + }, []) + .map(author => `Co-authored-by: ${author.name} <${author.email}>`) + .join('\n'); + console.log(authors); + return authors; + } catch (error) { + console.error('Error fetching commits:', error); + return null; + } + } - - name: Merge PR with Co-Authors - run: node index.mjs - name: Automerge PR uses: pascalgn/automerge-action@22948e0bc22f0aa673800da838595a3e7347e584 #v0.15.6 https://github.com/pascalgn/automerge-action/releases/tag/v0.15.6 env: @@ -47,4 +94,6 @@ jobs: # Important to keep 2 empty lines as https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors#creating-co-authored-commits-on-the-command-line mentions MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})\n\n\n${{ steps.authors.outputs.value }}" MERGE_RETRIES: "20" - MERGE_RETRY_SLEEP: "30000" \ No newline at end of file + MERGE_RETRY_SLEEP: "30000" + # Important to keep 2 empty lines as https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors#creating-co-authored-commits-on-the-command-line mentions + \ No newline at end of file From b6cde8e96a1feae82bca9556781b0947619c101c Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 12:43:44 +0530 Subject: [PATCH 06/30] test1 --- .../automerge-for-humans-merging.yml | 51 ++++++++----------- 1 file changed, 22 insertions(+), 29 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 5a9c2aaf..5221de5a 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -1,25 +1,20 @@ -# This workflow is centrally managed in https://github.com/asyncapi/.github/ -# Don't make changes to this file in this repo as they will be overwritten with changes made to the same file in above mentioned repo - -# Purpose of this workflow is to allow people to merge PR without a need of maintainer doing it. If all checks are in place (including maintainers approval) - JUST MERGE IT! name: Automerge For Humans on: - pull_request_target: - types: - - labeled - - unlabeled - - synchronize - - opened - - edited - - ready_for_review - - reopened - - unlocked + push: + branches: + - test jobs: automerge-for-humans: - if: github.event.pull_request.draft == false && (github.event.pull_request.user.login != 'asyncapi-bot' || github.event.pull_request.user.login != 'dependabot[bot]' || github.event.pull_request.user.login != 'dependabot-preview[bot]') #it runs only if PR actor is not a bot, at least not a bot that we know + if: + github.event.pull_request.draft == false && + (github.event.pull_request.user.login != 'asyncapi-bot' && + github.event.pull_request.user.login != 'dependabot[bot]' && + github.event.pull_request.user.login != 'dependabot-preview[bot]') + runs-on: ubuntu-latest + steps: - name: Checkout code uses: actions/checkout@v2 @@ -27,19 +22,17 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v2 with: - node-version: '18' + node-version: '14' # Use a supported Node.js version - name: Install dependencies run: npm install working-directory: ./.github/workflows/scripts/mailchimp - - name: Get list of authors - uses: actions/github-script@v5 + + - name: Get List of authors id: authors + uses: actions/github-script@v5 with: - GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" - PR_NUMBER: ${{ github.event.number }} - PR_TITLE: ${{ github.event.pull_request.title }} - GITHUB_REPOSITORY: ${{ github.repository }} + github-token: ${{ secrets.GH_TOKEN }} script: | const { Octokit } = require('@octokit/rest'); const { paginateRest } = require('@octokit/plugin-paginate-rest'); @@ -48,7 +41,7 @@ jobs: const prNumber = process.env.PR_NUMBER; const repository = process.env.GITHUB_REPOSITORY; - async function getCoAuthors() { + async function getCoAuthors() { try { const octokit = new Octokit({ auth: token }); const commitsResponse = await octokit.paginate("GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", { @@ -58,7 +51,7 @@ jobs: per_page: 100, }); - const authors = commitsResponse + const authors = commitsResponse .map(data => ({ name: data.commit.author.name, email: data.commit.author.email, @@ -81,6 +74,10 @@ jobs: } } + // Execute the function and set the output + const authorsOutput = await getCoAuthors(); + return { value: authorsOutput }; + - name: Automerge PR uses: pascalgn/automerge-action@22948e0bc22f0aa673800da838595a3e7347e584 #v0.15.6 https://github.com/pascalgn/automerge-action/releases/tag/v0.15.6 env: @@ -90,10 +87,6 @@ jobs: GITHUB_REPOSITORY: ${{ github.repository }} MERGE_LABELS: "!do-not-merge,ready-to-merge" MERGE_METHOD: "squash" - # Using the output of the previous step (`Co-authored-by: ...` lines) as commit description. - # Important to keep 2 empty lines as https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors#creating-co-authored-commits-on-the-command-line mentions - MERGE_COMMIT_MESSAGE: "{pullRequest.title} (#{pullRequest.number})\n\n\n${{ steps.authors.outputs.value }}" + MERGE_COMMIT_MESSAGE: "${{ github.event.pull_request.title }} (#${{ github.event.number }})\n\n\n${{ steps.authors.outputs.value }}" MERGE_RETRIES: "20" MERGE_RETRY_SLEEP: "30000" - # Important to keep 2 empty lines as https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors#creating-co-authored-commits-on-the-command-line mentions - \ No newline at end of file From 8d5814f4cc6048350f73db15e394676b8436ae4d Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 12:54:22 +0530 Subject: [PATCH 07/30] test2 --- .github/workflows/automerge-for-humans-merging.yml | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 5221de5a..2d0ba69e 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -25,14 +25,13 @@ jobs: node-version: '14' # Use a supported Node.js version - name: Install dependencies - run: npm install - working-directory: ./.github/workflows/scripts/mailchimp + run: npm install @octokit/core @octokit/plugin-paginate-rest - name: Get List of authors id: authors uses: actions/github-script@v5 with: - github-token: ${{ secrets.GH_TOKEN }} + github-token: ${{ secrets.GITHUB_TOKEN }} script: | const { Octokit } = require('@octokit/rest'); const { paginateRest } = require('@octokit/plugin-paginate-rest'); @@ -74,12 +73,8 @@ jobs: } } - // Execute the function and set the output - const authorsOutput = await getCoAuthors(); - return { value: authorsOutput }; - - - name: Automerge PR - uses: pascalgn/automerge-action@22948e0bc22f0aa673800da838595a3e7347e584 #v0.15.6 https://github.com/pascalgn/automerge-action/releases/tag/v0.15.6 + getCoAuthors(); + env: GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" PR_NUMBER: ${{ github.event.number }} From 5d359e113aa4aef91832d1473f6469af40f5e01e Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 12:57:24 +0530 Subject: [PATCH 08/30] test3 --- .github/workflows/automerge-for-humans-merging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 2d0ba69e..be877dcb 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -25,7 +25,7 @@ jobs: node-version: '14' # Use a supported Node.js version - name: Install dependencies - run: npm install @octokit/core @octokit/plugin-paginate-rest + run: npm install @octokit/core @octokit/plugin-paginate-rest @octokit/rest - name: Get List of authors id: authors From de5c07cf6a93585a5aad62bffc4138c2c13fff90 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:02:40 +0530 Subject: [PATCH 09/30] test 4 --- .github/workflows/automerge-for-humans-merging.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index be877dcb..fbd37e44 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -66,6 +66,7 @@ jobs: .map(author => `Co-authored-by: ${author.name} <${author.email}>`) .join('\n'); console.log(authors); + console.log(`::set-output name=authors::${authors}`); return authors; } catch (error) { console.error('Error fetching commits:', error); @@ -73,7 +74,8 @@ jobs: } } - getCoAuthors(); + await getCoAuthors(); + echo "::set-output name=value::${authors}" env: GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" From 0e3a75f0aa149e7880e5acac4d9da95efd3ae35b Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:03:52 +0530 Subject: [PATCH 10/30] test5 --- .github/workflows/automerge-for-humans-merging.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index fbd37e44..ec5fd452 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -75,7 +75,6 @@ jobs: } await getCoAuthors(); - echo "::set-output name=value::${authors}" env: GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" From 12ac86c43f7bd7e2ee35522411935a179df0a03c Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:05:40 +0530 Subject: [PATCH 11/30] test6 --- .github/workflows/automerge-for-humans-merging.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index ec5fd452..29ae19c4 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -25,7 +25,7 @@ jobs: node-version: '14' # Use a supported Node.js version - name: Install dependencies - run: npm install @octokit/core @octokit/plugin-paginate-rest @octokit/rest + run: npm install @octokit/core @octokit/plugin-paginate-rest @octokit/rest node-fetch - name: Get List of authors id: authors @@ -36,6 +36,8 @@ jobs: const { Octokit } = require('@octokit/rest'); const { paginateRest } = require('@octokit/plugin-paginate-rest'); + const fetch = require('node-fetch'); + const token = process.env.GITHUB_TOKEN; const prNumber = process.env.PR_NUMBER; const repository = process.env.GITHUB_REPOSITORY; From 4fbc0b1986ae6a9b672171d44d1e8cfd7d371853 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:09:29 +0530 Subject: [PATCH 12/30] test 7 --- .../workflows/automerge-for-humans-merging.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 29ae19c4..6743b3d4 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -36,7 +36,11 @@ jobs: const { Octokit } = require('@octokit/rest'); const { paginateRest } = require('@octokit/plugin-paginate-rest'); - const fetch = require('node-fetch'); + cconst fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args)); + + const token = process.env.GITHUB_TOKEN; + const prNumber = process.env.PR_NUMBER; + const repository = process.env.GITHUB_REPOSITORY; const token = process.env.GITHUB_TOKEN; const prNumber = process.env.PR_NUMBER; @@ -44,14 +48,20 @@ jobs: async function getCoAuthors() { try { - const octokit = new Octokit({ auth: token }); + const octokit = new Octokit({ + auth: token, + request: { + fetch, + }, + }); + const commitsResponse = await octokit.paginate("GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", { owner: "asyncapi", repo: repository, pull_number: prNumber, per_page: 100, }); - + const authors = commitsResponse .map(data => ({ name: data.commit.author.name, @@ -75,7 +85,7 @@ jobs: return null; } } - + await getCoAuthors(); env: From f495071815d1e5956c2baad007fd00725a64ae23 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:11:36 +0530 Subject: [PATCH 13/30] test 8 --- .github/workflows/automerge-for-humans-merging.yml | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 6743b3d4..d2d23c5b 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -36,11 +36,7 @@ jobs: const { Octokit } = require('@octokit/rest'); const { paginateRest } = require('@octokit/plugin-paginate-rest'); - cconst fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args)); - - const token = process.env.GITHUB_TOKEN; - const prNumber = process.env.PR_NUMBER; - const repository = process.env.GITHUB_REPOSITORY; + const fetch = require('node-fetch'); const token = process.env.GITHUB_TOKEN; const prNumber = process.env.PR_NUMBER; From 21f6abe6caa1237d57e242df223cfa3a8c661db7 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:12:28 +0530 Subject: [PATCH 14/30] test 9 --- .github/workflows/automerge-for-humans-merging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index d2d23c5b..0023ccb8 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -36,7 +36,7 @@ jobs: const { Octokit } = require('@octokit/rest'); const { paginateRest } = require('@octokit/plugin-paginate-rest'); - const fetch = require('node-fetch'); + const fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args)); const token = process.env.GITHUB_TOKEN; const prNumber = process.env.PR_NUMBER; From 654fdaa8bc8ac5aadb31570987d1612a7d909762 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:15:11 +0530 Subject: [PATCH 15/30] test 10 --- .github/workflows/automerge-for-humans-merging.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 0023ccb8..8ec80d97 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -41,6 +41,7 @@ jobs: const token = process.env.GITHUB_TOKEN; const prNumber = process.env.PR_NUMBER; const repository = process.env.GITHUB_REPOSITORY; + const pull_number = process.env.PR_NUMBER; async function getCoAuthors() { try { From f49dda80ab500752f2f56ace2d4ffebe7d7cb045 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:19:17 +0530 Subject: [PATCH 16/30] test 11 --- .github/workflows/automerge-for-humans-merging.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 8ec80d97..0023ccb8 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -41,7 +41,6 @@ jobs: const token = process.env.GITHUB_TOKEN; const prNumber = process.env.PR_NUMBER; const repository = process.env.GITHUB_REPOSITORY; - const pull_number = process.env.PR_NUMBER; async function getCoAuthors() { try { From aedb9503e93656d9f0e090f30986c58590c3c14d Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:23:38 +0530 Subject: [PATCH 17/30] test 12 --- .github/workflows/automerge-for-humans-merging.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 0023ccb8..fd7f6293 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -22,7 +22,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v2 with: - node-version: '14' # Use a supported Node.js version + node-version: '18' - name: Install dependencies run: npm install @octokit/core @octokit/plugin-paginate-rest @octokit/rest node-fetch @@ -53,8 +53,8 @@ jobs: const commitsResponse = await octokit.paginate("GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", { owner: "asyncapi", - repo: repository, - pull_number: prNumber, + repo: "parser-js", + pull_number: 526, per_page: 100, }); From a69126729d0adc3729e0cf21d51dd94a7edb69fa Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:26:04 +0530 Subject: [PATCH 18/30] test 13 --- .github/workflows/automerge-for-humans-merging.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index fd7f6293..22384973 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -22,7 +22,7 @@ jobs: - name: Setup Node.js uses: actions/setup-node@v2 with: - node-version: '18' + node-version: '16' - name: Install dependencies run: npm install @octokit/core @octokit/plugin-paginate-rest @octokit/rest node-fetch @@ -36,7 +36,7 @@ jobs: const { Octokit } = require('@octokit/rest'); const { paginateRest } = require('@octokit/plugin-paginate-rest'); - const fetch = (...args) => import('node-fetch').then(({ default: fetch }) => fetch(...args)); + const fetch = require('node-fetch'); const token = process.env.GITHUB_TOKEN; const prNumber = process.env.PR_NUMBER; From b9c0efe551724b8c4d130c899e8f4c39d44961b3 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:28:39 +0530 Subject: [PATCH 19/30] test14 --- .github/workflows/automerge-for-humans-merging.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 22384973..f6285b8b 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -25,7 +25,7 @@ jobs: node-version: '16' - name: Install dependencies - run: npm install @octokit/core @octokit/plugin-paginate-rest @octokit/rest node-fetch + run: npm install @octokit/core @octokit/plugin-paginate-rest @octokit/rest node-fetch@2 - name: Get List of authors id: authors @@ -36,7 +36,7 @@ jobs: const { Octokit } = require('@octokit/rest'); const { paginateRest } = require('@octokit/plugin-paginate-rest'); - const fetch = require('node-fetch'); + const fetch = require('node-fetch@2'); const token = process.env.GITHUB_TOKEN; const prNumber = process.env.PR_NUMBER; From f83790adf9b2d7de69fd70e72d8f42872c3cd9de Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:30:09 +0530 Subject: [PATCH 20/30] test 15 --- .github/workflows/automerge-for-humans-merging.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index f6285b8b..f25a6cc0 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -25,7 +25,7 @@ jobs: node-version: '16' - name: Install dependencies - run: npm install @octokit/core @octokit/plugin-paginate-rest @octokit/rest node-fetch@2 + run: npm install @octokit/core @octokit/plugin-paginate-rest @octokit/rest cross-fetch - name: Get List of authors id: authors @@ -36,7 +36,7 @@ jobs: const { Octokit } = require('@octokit/rest'); const { paginateRest } = require('@octokit/plugin-paginate-rest'); - const fetch = require('node-fetch@2'); + const fetch = require('cross-fetch'); const token = process.env.GITHUB_TOKEN; const prNumber = process.env.PR_NUMBER; From a7b9fad0435f8ceb34f399f7b4da1e1778764781 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:42:49 +0530 Subject: [PATCH 21/30] test 16 --- .github/workflows/automerge-for-humans-merging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index f25a6cc0..c21dea8b 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -74,7 +74,7 @@ jobs: .map(author => `Co-authored-by: ${author.name} <${author.email}>`) .join('\n'); console.log(authors); - console.log(`::set-output name=authors::${authors}`); + console.log(`::save-state name=authors::${authors}`); return authors; } catch (error) { console.error('Error fetching commits:', error); From 0a0c2b8175cbf702a2f60fa02bd3829c5cf6a538 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 13:47:45 +0530 Subject: [PATCH 22/30] test 17 --- .github/workflows/automerge-for-humans-merging.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index c21dea8b..fa03f21d 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -74,7 +74,6 @@ jobs: .map(author => `Co-authored-by: ${author.name} <${author.email}>`) .join('\n'); console.log(authors); - console.log(`::save-state name=authors::${authors}`); return authors; } catch (error) { console.error('Error fetching commits:', error); From d4b902d60f9c4ccb6467b149ba90b330f23e6580 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 15:11:37 +0530 Subject: [PATCH 23/30] final test --- .../automerge-for-humans-merging.yml | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index fa03f21d..ae3741aa 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -1,9 +1,16 @@ name: Automerge For Humans on: - push: - branches: - - test + pull_request_target: + types: + - labeled + - unlabeled + - synchronize + - opened + - edited + - ready_for_review + - reopened + - unlocked jobs: automerge-for-humans: @@ -53,8 +60,8 @@ jobs: const commitsResponse = await octokit.paginate("GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", { owner: "asyncapi", - repo: "parser-js", - pull_number: 526, + repo: repository, + pull_number: prNumber, per_page: 100, }); @@ -82,6 +89,8 @@ jobs: } await getCoAuthors(); + - name: Automerge PR + uses: pascalgn/automerge-action@v0.15.6 env: GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" @@ -90,6 +99,8 @@ jobs: GITHUB_REPOSITORY: ${{ github.repository }} MERGE_LABELS: "!do-not-merge,ready-to-merge" MERGE_METHOD: "squash" + # Using the output of the previous step (`Co-authored-by: ...` lines) as commit description. + # Important to keep 2 empty lines as https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors#creating-co-authored-commits-on-the-command-line mentions MERGE_COMMIT_MESSAGE: "${{ github.event.pull_request.title }} (#${{ github.event.number }})\n\n\n${{ steps.authors.outputs.value }}" MERGE_RETRIES: "20" MERGE_RETRY_SLEEP: "30000" From afce4c28758bd8c0a89af88a3d10d029cb6c5dfa Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 15:19:44 +0530 Subject: [PATCH 24/30] added correct structure --- .github/workflows/automerge-for-humans-merging.yml | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index ae3741aa..619e097e 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -42,7 +42,6 @@ jobs: script: | const { Octokit } = require('@octokit/rest'); const { paginateRest } = require('@octokit/plugin-paginate-rest'); - const fetch = require('cross-fetch'); const token = process.env.GITHUB_TOKEN; @@ -89,14 +88,11 @@ jobs: } await getCoAuthors(); - - name: Automerge PR - uses: pascalgn/automerge-action@v0.15.6 + - name: Automerge PR + uses: pascalgn/automerge-action@v0.15.6 env: GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" - PR_NUMBER: ${{ github.event.number }} - PR_TITLE: ${{ github.event.pull_request.title }} - GITHUB_REPOSITORY: ${{ github.repository }} MERGE_LABELS: "!do-not-merge,ready-to-merge" MERGE_METHOD: "squash" # Using the output of the previous step (`Co-authored-by: ...` lines) as commit description. From 547fa6d90db1101a6e083681192b3bb951ee6dfe Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 15:41:24 +0530 Subject: [PATCH 25/30] added the owner --- .github/workflows/automerge-for-humans-merging.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 619e097e..3ce49263 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -58,7 +58,7 @@ jobs: }); const commitsResponse = await octokit.paginate("GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", { - owner: "asyncapi", + owner: "${{ github.repository_owner }}", repo: repository, pull_number: prNumber, per_page: 100, @@ -92,7 +92,7 @@ jobs: - name: Automerge PR uses: pascalgn/automerge-action@v0.15.6 env: - GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" MERGE_LABELS: "!do-not-merge,ready-to-merge" MERGE_METHOD: "squash" # Using the output of the previous step (`Co-authored-by: ...` lines) as commit description. From 6e77f4a387914db8dcbd3bee308ff0ca915acd60 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 15:45:39 +0530 Subject: [PATCH 26/30] added repo correctly --- .github/workflows/automerge-for-humans-merging.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 3ce49263..52678547 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -59,7 +59,7 @@ jobs: const commitsResponse = await octokit.paginate("GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", { owner: "${{ github.repository_owner }}", - repo: repository, + repo: repository.split('/')[1], pull_number: prNumber, per_page: 100, }); From b2e4a056011c94bd07ad678fe407e6dc1601ae1e Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 15:54:38 +0530 Subject: [PATCH 27/30] cleanup --- .github/workflows/automerge-for-humans-merging.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 52678547..912fbcec 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -45,8 +45,8 @@ jobs: const fetch = require('cross-fetch'); const token = process.env.GITHUB_TOKEN; - const prNumber = process.env.PR_NUMBER; - const repository = process.env.GITHUB_REPOSITORY; + const prNumber = ${{ github.event.number }}; + const repository = ${{ github.repository }} async function getCoAuthors() { try { From d4b883a85e76bb5b8c862f58f11640810ba71100 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 15:56:52 +0530 Subject: [PATCH 28/30] final addition --- .../automerge-for-humans-merging.yml | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 912fbcec..1b6cc779 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -42,11 +42,12 @@ jobs: script: | const { Octokit } = require('@octokit/rest'); const { paginateRest } = require('@octokit/plugin-paginate-rest'); + const fetch = require('cross-fetch'); const token = process.env.GITHUB_TOKEN; - const prNumber = ${{ github.event.number }}; - const repository = ${{ github.repository }} + const prNumber = process.env.PR_NUMBER; + const repository = process.env.GITHUB_REPOSITORY; async function getCoAuthors() { try { @@ -58,9 +59,9 @@ jobs: }); const commitsResponse = await octokit.paginate("GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", { - owner: "${{ github.repository_owner }}", - repo: repository.split('/')[1], - pull_number: prNumber, + owner: "asyncapi", + repo: repository, + pull_number: ${{ github.event.number }}, per_page: 100, }); @@ -88,11 +89,14 @@ jobs: } await getCoAuthors(); + - name: Automerge PR + uses: pascalgn/automerge-action@v0.15.6 - - name: Automerge PR - uses: pascalgn/automerge-action@v0.15.6 env: - GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" + PR_NUMBER: ${{ github.event.number }} + PR_TITLE: ${{ github.event.pull_request.title }} + GITHUB_REPOSITORY: ${{ github.repository }} MERGE_LABELS: "!do-not-merge,ready-to-merge" MERGE_METHOD: "squash" # Using the output of the previous step (`Co-authored-by: ...` lines) as commit description. From 2ff2bd3804c77f0fb7f3e5f3f68aa509b20680cb Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 16:00:35 +0530 Subject: [PATCH 29/30] uff --- .github/workflows/automerge-for-humans-merging.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 1b6cc779..9a141732 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -59,8 +59,8 @@ jobs: }); const commitsResponse = await octokit.paginate("GET /repos/{owner}/{repo}/pulls/{pull_number}/commits", { - owner: "asyncapi", - repo: repository, + owner: repository.split('/')[0], + repo: repository.split('/')[1], pull_number: ${{ github.event.number }}, per_page: 100, }); @@ -93,7 +93,7 @@ jobs: uses: pascalgn/automerge-action@v0.15.6 env: - GITHUB_TOKEN: "${{ secrets.GH_TOKEN }}" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" PR_NUMBER: ${{ github.event.number }} PR_TITLE: ${{ github.event.pull_request.title }} GITHUB_REPOSITORY: ${{ github.repository }} From 663961dd2611e1d79f9c257f3e9e51855e655a24 Mon Sep 17 00:00:00 2001 From: Mintu Date: Sun, 14 Jan 2024 16:04:28 +0530 Subject: [PATCH 30/30] my god --- .github/workflows/automerge-for-humans-merging.yml | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/.github/workflows/automerge-for-humans-merging.yml b/.github/workflows/automerge-for-humans-merging.yml index 9a141732..784a255d 100644 --- a/.github/workflows/automerge-for-humans-merging.yml +++ b/.github/workflows/automerge-for-humans-merging.yml @@ -89,18 +89,13 @@ jobs: } await getCoAuthors(); - - name: Automerge PR - uses: pascalgn/automerge-action@v0.15.6 - + + - name: Automerge PR + uses: pascalgn/automerge-action@v0.15.6 env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - PR_NUMBER: ${{ github.event.number }} - PR_TITLE: ${{ github.event.pull_request.title }} - GITHUB_REPOSITORY: ${{ github.repository }} MERGE_LABELS: "!do-not-merge,ready-to-merge" MERGE_METHOD: "squash" - # Using the output of the previous step (`Co-authored-by: ...` lines) as commit description. - # Important to keep 2 empty lines as https://docs.github.com/en/pull-requests/committing-changes-to-your-project/creating-and-editing-commits/creating-a-commit-with-multiple-authors#creating-co-authored-commits-on-the-command-line mentions MERGE_COMMIT_MESSAGE: "${{ github.event.pull_request.title }} (#${{ github.event.number }})\n\n\n${{ steps.authors.outputs.value }}" MERGE_RETRIES: "20" MERGE_RETRY_SLEEP: "30000"