A GitHub Action that listens for a /assign
"command" (an issue comment that starts with /assign
) and assigns the commenter to the issue. It can also unassign issues that have been assigned for a configured amount of time.
name: Slash assign
on:
schedule:
- cron: 0 0 * * *
issue_comment:
types: [created]
jobs:
slash_assign:
# If the acton was triggered by a new comment that starts with `/assign`
# or a on a schedule
if: >
(github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/assign')) ||
github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Assign the user or unassign stale assignments
uses: JasonEtco/slash-assign-action@v1
with:
required_label: good-first-issue
assigned_label: assigned-to-contributor
That big if
property is there to prevent the action from running if it doesn't need to. Without it, it'll run on every single issue comment, and that can eat up your Actions minutes. The Action itself also checks for the /assign
comment.
A label that is added to issues when they're assigned, to track which issues were assigned by this action. Default: slash-assigned
If set, the issue must have this label to be assigned.
The span of time (in days) between a user assigning themselves to the action commenting saying it will become unassigned. Default: 14
The span of time (in days) between a warning (see days_until_warning
) and the issue being unassigned automatically. Default: 7
The label applied when the assignment is stale (>= days_until_warning
). Default: stale-assignment
.
A label that prevents the user from being unassigned, typically for issues that are expected to take a long time. Default: pinned
.
The comment posted after a user has assigned themselves to an issue. This is a Mustache template that supports the following variables:
inputs
(the inputs given to the action)comment
(an object of the comment that was created)totalDays
(days_until_warning
+days_until_unassign
)env
(process.env
, anything you pass to the action viaenv
)
Default:
This issue [has been assigned]({{ comment.html_url }}) to {{ comment.user.login }}!
It will become unassigned if it isn't closed within {{ totalDays }} days. A maintainer can also add the **{{ inputs.pin_label }}** label to prevent it from being unassigned.
The comment posted to warn a user that the issue will become unassigned. This is a Mustache template that supports the following variables:
user
(the user that was assigned)inputs
(the inputs given to the action)env
(process.env
, anything you pass to the action viaenv
)
Default:
@{{ assignee.login }}, this issue hasn't had any activity in {{ inputs.days_until_warning }} days.
It will become unassigned in {{ inputs.days_until_unassign }} days to make room for someone else to contribute.
You can also manually trigger this action via the workflow_dispatch
event. You'll need to modify the if
property:
if: >
(github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/assign')) ||
github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'