When you’re the only maintainer of a repository, every new issue and pull request is yours anyway. Still, I like having the assignee field filled in. It makes GitHub’s “assigned to me” filters useful and keeps things working if more people join later. Doing this by hand is the kind of chore I forget, so I automated it with a small GitHub Actions workflow.
The workflow
I used gustavofreze/auto-assign. It assigns the issue or pull request that triggered the workflow to the logins you specify. Create .github/workflows/auto-assign.yml:
name: Auto assign
on:
issues:
types:
- opened
pull_request:
types:
- opened
jobs:
run:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- name: Auto assigns assignees
uses: gustavofreze/auto-assign@3.0.0
with:
assignees: 'your-github-login'
assignment_options: 'ISSUE,PULL_REQUEST'
How it works
- Triggers: The workflow runs when an issue or pull request is opened. For these events, the action only touches the item that triggered the run, and only if it has no assignee yet. A pull request event never assigns issues, and an issue event never assigns pull requests.
assignment_options: The default isISSUE. Set it toISSUE,PULL_REQUESTto cover both.- Permissions: The job needs
issues: writeandpull-requests: write. The default workflow token is enough, so there’s no secret to create or rotate. - Pinning: I pinned the action to the
3.0.0tag. For stricter supply-chain hygiene, you can pin it to a commit SHA instead.
Options worth knowing about
The action has a few inputs I didn’t need but you might:
| Input | Default | What it does |
|---|---|---|
skip_bots |
false |
Skips items opened by bots such as dependabot[bot] |
skip_drafts |
false |
Skips draft pull requests |
assign_author |
false |
Also assigns the author of the item |
allow_no_assignees |
false |
Lets the run succeed when nobody can be assigned |
Caveats
- Forks: On the
pull_requestevent, pull requests from forks get a read-only token, so assignment will fail for them. That doesn’t matter for a personal repo. If you accept outside contributions, you would needpull_request_target, which has its own security trade-offs. - Default branch: The
issuestrigger only fires once the workflow file is on the default branch. Thepull_requesttrigger uses the workflow file from the pull request itself, so the PR that introduces the workflow is its first test.
It’s a 23-line file that removes one small manual step. I opened the pull request that adds it on a branch of its own so I could see whether it assigned itself.
If this post was enjoyable or useful for you, please share it! If you have comments, questions, or feedback, you can email my personal email. To get new posts, subscribe use the RSS feed.