Skip to content
users

GitHub Action

Get GitHub team members

v1 Latest version

Get GitHub team members

users

Get GitHub team members

Retrieve team members from a GitHub team

Installation

Copy and paste the following snippet into your .yml file.

              

- name: Get GitHub team members

uses: garnertb/get-team-members@v1

Learn more about this action in garnertb/get-team-members

Choose a version

get-team-members

This action fetches the users of a GitHub team.

Usage

- uses: garnertb/get-team-members@v1
  with:
    # Name of the organization that the team is a part of.
    # (required)
    org: ''

    # Name of the team to get the members of.
    # (required)
    team_slug: ''

    # The role to filter team members by.
    # Must be one of: 'member', 'maintainer', 'all'.
    # Default: 'all'
    role: ''

    # Personal access token (PAT) used to fetch team members. 
    # Note the PAT must be entitled to at least `read:org` scope.
    # Default: ${{ github.token }}
    token: ''

Permissions

The GitHub token needs to have read:org permissions to read organizational team members.

Scenerios

Fetch handles for all members of a team

- id: get-members
  uses: garnertb/get-team-members@v1
  with:
    org: garnertb-io
    team_slug: ops
    token: ${{ secrets.GITHUB_TOKEN }}

- run: "echo ${{ steps.get-members.outputs.members }}"
  shell: bash

Fetch handles for the maintainers of a team

- id: get-members
  uses: garnertb/get-team-members@v1
  with:
    org: garnertb-io
    team_slug: ops
    role: maintainer
    token: ${{ secrets.GITHUB_TOKEN }}

# print results
- run: "echo ${{ steps.get-members.outputs.members }}"
  shell: bash

Access additional member properties

Raw member data is accessible via the data output and can be manipulated with jq.

- id: get-members
  uses: garnertb/get-team-members@v1
  with:
    org: garnertb-io
    team_slug: ops
    role: maintainer
    token: ${{ secrets.GITHUB_TOKEN }}

  - run: "echo '${{ steps.get-members.outputs.data }}' | jq '.[] | {login: .login, id: .id}'"
    shell: bash

Results:

{
  "login": "garnertb",   
  "id": 1234
}

Assign team members to issue

Use this action to set assignees for a new issue with issue-bot.

- id: get-members
  uses: garnertb/get-team-members@v1
  with:
    org: garnertb-io
    team_slug: ops
    role: maintainer
    token: ${{ secrets.GITHUB_TOKEN }}

- name: Create new issue
  uses: imjohnbo/issue-bot@v3
  with:
    assignees: ${{ steps.get-members.outputs.members }}
    title: Hello, world
    body: |-
      :wave: Hi, {{#each assignees}}@{{this}}{{#unless @last}}, {{/unless}}{{/each}}!