A GitHub Action to determine the next team member in a rotation.
This GitHub Action is meant to be used to assist with creating issues or PRs for tasks that rotate through a team. For example:
# .github/workflows/weekly-issue
on:
schedule:
- cron: 0 20 * * 2
name: Create weekly issue
jobs:
stuff:
steps:
- uses: lee-dohm/last-assigned@v1
with:
query: 'label:weekly-issue'
token: ${{ secrets.GITHUB_TOKEN }}
id: assigned
- uses: lee-dohm/team-rotation@v1
with:
last: ${{ steps.assigned.outputs.last }}
include: octocat lee-dohm
id: rotation
- uses: JasonEtco/create-an-issue@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: .github/weekly-issue-template.md
assignees: ${{ steps.rotation.outputs.next }}
This workflow:
- Gets the person that was assigned to the last issue opened that matches the query
label:weekly-issue
- Determines the next person in the team rotation after the person found in step 1
- Creates a new issue based on the
.github/weekly-issue-template.md
template and assigns the person found in step 2
exclude
-- Space-separated list of GitHub handles to remove from the listinclude
-- Space-separated list of GitHub handles to add to the list generated byteamName
, if anylast
-- GitHub handle of the last person to be assigned from the rotationteamName
-- The name of a GitHub team, ex:@org-name/team-name
. If this parameter is specified,token
is required.token
-- Token to use to perform the query of members inteamName
. Please note: Because the defaultGITHUB_TOKEN
doesn't have access to query organization team members, you'll have to create a personal access token with access to organization information and create a secret for it
next
-- GitHub handle of the next person in the rotation
The next person in the rotation is determined by:
- Getting the list of handles associated with
teamName
, if any - Adding any handles from
include
- Removing any handles in
exclude
- Removing any duplicates in the list
- Sorting the list alphabetically
- Finding the handle specified in
last
in the list - Taking the next handle in the list, if there are no more in the list, use the first handle in the list