From f4edd193718024c4f79c563e4fdddda77e48bc25 Mon Sep 17 00:00:00 2001 From: Sidharth Vinod Date: Thu, 10 Jul 2025 01:00:10 +0530 Subject: [PATCH] chore: Add auto labeler for Sponsored work --- .github/workflows/pr-labeler.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml index 44860845f..18bc7c6c5 100644 --- a/.github/workflows/pr-labeler.yml +++ b/.github/workflows/pr-labeler.yml @@ -29,3 +29,29 @@ jobs: disable-releaser: true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + + - name: Add "Sponsored by MermaidChart" label + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + script: | + const prNumber = context.payload.pull_request.number; + const { data: commits } = await github.rest.pulls.listCommits({ + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: prNumber, + }); + + const isSponsored = commits.some( + (c) => c.commit.author.email?.endsWith('@mermaidchart.com') + ); + + if (isSponsored) { + console.log('PR is sponsored. Adding label.'); + await github.rest.issues.addLabels({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: prNumber, + labels: ['Sponsored by MermaidChart'], + }); + }