Skip to content

Commit

Permalink
chore: adjust merge contributors workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
nartc committed Sep 18, 2023
1 parent 06ca1f5 commit 9bf2827
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions .github/scripts/merge-all-contributors.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@ module.exports = async ({ github, context }) => {
const owner = context.payload.repository.owner.login;
const repo = context.payload.repository.name;

console.log(
`[merge contributors workflow] merging ${prNumber} on ${owner}/${repo}`
);
const comments = await github.rest.issues.listComments({
owner,
repo,
Expand All @@ -20,14 +17,26 @@ module.exports = async ({ github, context }) => {

for (const comment of comments?.data || []) {
if (comment.user.login.includes('allcontributors')) {
console.log(
`[merge contributors workflow] found all-contributors comment ${comment.body}`
);
const allContributorsPr = comment.body.match(/\/pull\/(\d+)/)?.[1];

if (allContributorsPr) {
const pr = await github.rest.pulls.get({
owner,
repo,
pull_number: allContributorsPr,
});

console.log(
`[merge contributors workflow] found all-contributors PR ${pr}`
);

if (pr && pr.mergeable) {
console.log(
`[merge contributors workflow] merging ${allContributorsPr} on ${owner}/${repo}`
);
await github.rest.pulls.merge({
owner,
repo,
Expand Down

0 comments on commit 9bf2827

Please sign in to comment.