From 5ce6c594fad9dca546eb616aba9c280b22826ddf Mon Sep 17 00:00:00 2001 From: "sentry-junior[bot]" <264270552+sentry-junior[bot]@users.noreply.github.com> Date: Mon, 19 Oct 2026 13:42:31 +0000 Subject: [PATCH] ci(v10): Assign Junior backport PRs to the original author MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Jan VamPeer Stöcklmair --- .github/workflows/assign-v10-backports.yml | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 .github/workflows/assign-v10-backports.yml diff --git a/.github/workflows/assign-v10-backports.yml b/.github/workflows/assign-v10-backports.yml new file mode 100644 index 000000000000..d8e086955175 --- /dev/null +++ b/.github/workflows/assign-v10-backports.yml @@ -0,0 +1,59 @@ +name: 'Automation: Assign v10 backport PRs' + +on: + pull_request_target: + types: + - opened + - reopened + - edited + branches: + - v10 + +jobs: + assign_backport: + name: Assign original PR author + permissions: + pull-requests: write + runs-on: ubuntu-24.04 + if: | + github.event.pull_request.user.login == 'sentry-junior[bot]' + && toJSON(github.event.pull_request.assignees) == '[]' + steps: + - name: Assign original author or merger + uses: actions/github-script@v9 + with: + script: | + const { owner, repo } = context.repo; + const backport = context.payload.pull_request; + + const match = /^Backport of:\s*#(\d+)/m.exec(backport.body ?? ''); + if (!match) { + core.info('No "Backport of: #" reference found, skipping.'); + return; + } + + const { data: original } = await github.rest.pulls.get({ + owner, + repo, + pull_number: Number(match[1]), + }); + + const isInternal = + ['MEMBER', 'OWNER', 'COLLABORATOR'].includes(original.author_association) && + original.user.type !== 'Bot'; + + const assignee = isInternal ? original.user.login : original.merged_by?.login; + if (!assignee) { + core.info(`Could not determine an assignee from #${original.number}, skipping.`); + return; + } + + core.info( + `Assigning ${assignee} (${isInternal ? 'author' : 'merger'} of #${original.number}) to #${backport.number}.`, + ); + await github.rest.issues.addAssignees({ + owner, + repo, + issue_number: backport.number, + assignees: [assignee], + });