Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .github/workflows/pr-auto-assignee.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ on:
description: 'A list of reviewers(GitHub user name) to be added to PRs'
required: false
type: string
assign_yourself:
description: 'Whether to assign the PR opener as an assignee'
required: false
type: boolean
default: true
secrets:
GITHUB:
description: 'Your GitHub token for authentication.'
Expand All @@ -27,4 +32,18 @@ jobs:
assignees: ${{ inputs.assignees }}
reviewers: ${{ inputs.reviewers }}
skipKeywords: wip, draft

- uses: actions/github-script@v7
if: ${{ inputs.assign_yourself }}
with:
github-token: ${{ secrets.GITHUB }}
script: |
const opener = context.payload.pull_request.user.login;

await github.rest.issues.addAssignees({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
assignees:[ opener ]
});
...
14 changes: 12 additions & 2 deletions docs/pr-auto-assignee.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,16 @@
This workflow automates process for assigning assignees to the PR which would opened or reopened from a users list. Workflows have been added in `.github/workflows/pr-auto-assignee.yml`

#### Usage
Below workflow can be used to automatically assign the assignee to a pull request (PR) when the request is opened or reopened from the specified branch. If we provide a list of users, it will randomly select one user and assign as assignee to the PR.
This workflow can be used to automatically assign assignees to a PR when it is opened or reopened.
* If a list of users is provided, one user will be randomly selected and assigned.
* You can also enable assigning the PR opener to themselves using the `assign_yourself` flag.

| Name | Description | Required | Type |
| ----------------- | ----------------------------------------------------- | -------- | ------- |
| `assignees` | List of GitHub usernames to randomly assign to the PR | No | String |
| `assign_yourself` | Whether to assign the PR creator as an assignee | No | Boolean |



#### Example
```yaml
Expand All @@ -20,5 +29,6 @@ jobs:
secrets:
GITHUB: ${{ secrets.TOKEN_GITHUB }}
with:
assignees: #list of usernames of assignees
assignees: user1,user2,user3 # List of usernames
assign_yourself: true # Assign PR creator as assignee
```
Loading