Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add github/team/view action #201

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
36 changes: 36 additions & 0 deletions github/team/view/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: "View GitHub team"
description: "Get metadata about a GitHub team"

inputs:
team:
description: "The name of the team"
required: true

outputs:
members:
description: "A space delimited list of team members"
value: ${{ steps.team.outputs.members }}

runs:
using: composite
steps:
- name: "[DEBUG] Inputs"
shell: bash
run: |
echo "==========INPUTS=========="
echo team : ${{ inputs.team }}

- name: "Get team metadata"
id: team
shell: bash
run: ./github/team/view/get_team_metadata.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More logic hidden in a script.

env:
ENDPOINT: "orgs/dbt-labs/teams/${{ inputs.team }}/members"
HEADER: "Accept: application/vnd.github+json"
GH_TOKEN: ${{ secrets.IT_TEAM_MEMBERSHIP }}

- name: "[DEBUG] Outputs"
shell: bash
run: |
echo "==========OUTPUTS=========="
echo members : ${{ steps.team.outputs.members }}
9 changes: 9 additions & 0 deletions github/team/view/get_team_metadata.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
OUTPUT_FILE=output_$GITHUB_RUN_ID.json

gh api $ENDPOINT -H "$HEADER" > $OUTPUT_FILE

team_list=$(jq -r '.[].login' $OUTPUT_FILE)
team_list_single=$(echo $team_list | tr '\n' ' ')
echo "members=$team_list_single" >> $GITHUB_OUTPUT

rm $OUTPUT_FILE