From 9f114e55d2dbe7e40a9ee83cee65ccf305960cd7 Mon Sep 17 00:00:00 2001 From: Taewoon Kim Date: Tue, 10 Nov 2026 01:04:42 +0900 Subject: [PATCH] CI: assign every new issue and pull request to the maintainer The workflow runs on issues and pull_request_target opened events and adds tae898 as assignee through the REST API. pull_request_target so a fork's pull request still gets a token that can edit it; nothing from the pull request head is checked out or run. A refused assignment logs a warning and does not fail the job. Closes #341 Co-Authored-By: Claude Sonnet 5.5 --- .github/workflows/assign-maintainer.yml | 50 +++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 .github/workflows/assign-maintainer.yml diff --git a/.github/workflows/assign-maintainer.yml b/.github/workflows/assign-maintainer.yml new file mode 100644 index 0000000..c09ba67 --- /dev/null +++ b/.github/workflows/assign-maintainer.yml @@ -0,0 +1,50 @@ +# Assigns every new issue and pull request to the maintainer, as it is opened. +# +# Without this an item has no assignee until someone sets one by hand, and the maintainer wants to see each +# one in their own queue from the first minute. The only thing to change is the `maintainer` login in the +# script below. A pull request that already has the maintainer assigned is left alone, and an assignment +# the API refuses (a bot, a fork pull request) is logged as a warning and never fails the job. +# +# `pull_request_target` so a fork's pull request still gets a token that can edit it. Nothing from the pull +# request head is checked out or run: the job calls the GitHub API only. +# +# REMOVE WHEN: nothing, this stays for as long as the repository has a maintainer to assign. +name: Assign the maintainer + +on: + issues: + types: [opened] + pull_request_target: + types: [opened] + +permissions: + issues: write + # assigning a pull request needs pull-requests: write (issues: write covers issues only) + pull-requests: write + contents: read + +jobs: + assign: + name: Assign the maintainer + runs-on: ubuntu-latest + timeout-minutes: 5 + steps: + - name: Assign the maintainer + uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 + with: + script: | + const maintainer = 'tae898'; + const { owner, repo } = context.repo; + const item = context.payload.issue ?? context.payload.pull_request; + const number = item.number; + + if (item.assignees.some((a) => a.login.toLowerCase() === maintainer.toLowerCase())) { + core.info(`#${number}: ${maintainer} is already assigned.`); + return; + } + try { + await github.rest.issues.addAssignees({ owner, repo, issue_number: number, assignees: [maintainer] }); + core.info(`#${number}: assigned to ${maintainer}.`); + } catch (error) { + core.warning(`#${number}: could not assign ${maintainer}: ${error.message}`); + }