diff --git a/.github/workflows/approve-contributor.yml b/.github/workflows/approve-contributor.yml index ab041be9..794efad6 100644 --- a/.github/workflows/approve-contributor.yml +++ b/.github/workflows/approve-contributor.yml @@ -96,10 +96,19 @@ jobs: } function stringifyApprovedUsers(entries) { - return `${entries + const normalizedEntries = [...entries]; + + while (normalizedEntries.length > 0) { + const lastEntry = normalizedEntries[normalizedEntries.length - 1]; + if (lastEntry.type !== 'other' || lastEntry.line.trim() !== '') { + break; + } + normalizedEntries.pop(); + } + + return `${normalizedEntries .map((entry) => (entry.type === 'user' ? `${entry.username} ${entry.capability}` : entry.line)) - .join('\n') - .replace(/\n+$/g, '')}\n`; + .join('\n')}\n`; } const content = fs.readFileSync(APPROVED_FILE, 'utf8'); @@ -168,14 +177,3 @@ jobs: body, }); - - name: Close issue after PR approval - if: (steps.update.outputs.status == 'added' || steps.update.outputs.status == 'updated') && steps.update.outputs.capability == 'pr' - uses: actions/github-script@v7 - with: - script: | - await github.rest.issues.update({ - owner: context.repo.owner, - repo: context.repo.repo, - issue_number: context.issue.number, - state: 'closed', - });