NVIDIA / NVIDIA/cccl

Replace hard-coded team members triage workflow with GitHub team information

Open
#78 0 comments 0 reactions 0 assignees View on GitHub
infra
Dominant language
C++
Stars
2.5k
Forks
487
Avg merge
2d 7h
Merged PRs (30d)
296

Description

This won't be possible yet because we don't have a GitHub team, but for future reference it is possible to update this to avoid needing to manually specify the list of users and instead automatically assign to members of a [GitHub Team](https://docs.github.com/en/organizations/organizing-members-into-teams/about-teams). From our friend ChatGPT:

```
Yes, it is possible to update the GitHub Actions workflow to automatically assign issues to members of a team in a GitHub organization, instead of manually specifying the list of users. Here are the general steps that you would need to follow:

Authenticate and authorize the workflow to access your GitHub organization. You can use a personal access token or a GitHub Actions token with the necessary permissions to access the organization.

Retrieve the team ID of the team in the GitHub organization that you want to automatically assign issues to. You can use the GitHub CLI (gh) or make a GraphQL API request to retrieve the team ID. For example, you can use the following GraphQL query to retrieve the team ID:

javascript

query {
organization(login: "ORG_NAME") {
team(slug: "TEAM_NAME") {
id
}
}
}

Replace ORG_NAME with the login name of your GitHub organization and TEAM_NAME with the slug (i.e., the URL-friendly name) of the team that you want to automatically assign issues to.

Update the workflow to use the retrieved team ID instead of the manually specified list of users (USERS). You can modify the Calculate assignee step to use the team ID to retrieve the members of the team, and then randomly select an assignee from the retrieved list of team members. Here's an example of how you can update the step:

bash

- name: Calculate assignee
id: calculate_assignee
run: |
TEAM_ID=
TEAM_MEMBERS=$(gh api graphql -f query='
query {
node(id: $TEAM_ID) {
... on Team {
members(first: 100) {
edges {
node {
login
}
}
}
}
}
}
')
ASSIGNEES=($(echo "$TEAM_MEMBERS" | jq -r '.data.node.members.edges[].node.login'))
INDEX=$(( RANDOM % ${#ASSIGNEES[@]} ))
echo "ASSIGNEE=${ASSIGNEES[$INDEX]}" >> $GITHUB_ENV

Replace with the team ID retrieved in step 2.

Update the Assign issue step to use the retrieved team ID and the randomly selected assignee to assign the issue to the team member. Here's an example of how you can update the step:

graphql

- name: Assign issue
run: |
gh api graphql -f query='
mutation {
addAssigneesToAssignable(input:
{assignableId: "${{ github.event.issue.node_id }}",
assigneeIds: [ ${{ env.ASSIGNEE_ID }} ]
})
{ clientMutationId }
}'

You can remove the Get User ID step since the assignee is now randomly selected from the team members in step 3.
```

_Originally posted by @jrhemstad in https://github.com/NVIDIA/cccl/pull/23#discussion_r1172479816_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.