Automatically assigns the pull request creator as the assignee when a new PR is opened.
This GitHub Action is useful for teams who want to ensure PR creators are always responsible for their own pull requests unless reassigned.
- Automatic Assignment: Instantly assigns the pull request creator as the assignee.
- Simple Integration: One-step usage in any workflow.
- Powered by GitHub CLI: Uses the official GitHub CLI for secure PR management.
- Organization-wide: Can be used across any repository.
- Your workflow must pass the pull request URL and creator login to this action.
- This action expects the GitHub CLI (
gh
) to be available (it is pre-installed on all GitHub-hosted runners). - The environment variable
GH_TOKEN
must be set to a valid GitHub token withrepo
andpull_requests
write permissions (by default,${{ github.token }}
will suffice for most repositories).
name: Auto Assign PR Creator
on:
pull_request:
types: [opened]
jobs:
auto-assign-pr-creator:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Auto-assign PR creator
uses: ws2git/gh-assigner-action@v1
env:
GH_TOKEN: ${{ github.token }}
with:
pr_url: ${{ github.event.pull_request.html_url }}
pr_creator: ${{ github.event.pull_request.user.login }}
Name | Required | Description |
---|---|---|
pr_url |
Yes | The URL of the pull request to assign |
pr_creator |
Yes | The GitHub username of the PR creator |
Internally, this action calls a shell script that uses the GitHub CLI to edit the pull request and add the creator as an assignee.
Script logic:
gh pr edit "$PR_LINK" --add-assignee "$PR_CREATOR"
If either parameter is missing, the script exits with an error.
- The action requires
pull-requests: write
permission to assign users to a PR. - By default,
${{ github.token }}
is sufficient if your repository allows actions to create and edit pull requests. - If your organization restricts
GITHUB_TOKEN
permissions, use a Personal Access Token (PAT) as a secret:env: GH_TOKEN: ${{ secrets.YOUR_PAT }}
If you find a bug or have a question, open an issue.