From 4072a8b98d256e79d2623c620e19582d58eda327 Mon Sep 17 00:00:00 2001 From: Mike Alfare Date: Fri, 3 May 2024 19:33:56 -0400 Subject: [PATCH] add view github team action --- github/team/view/action.yaml | 36 +++++++++++++++++++++++++++ github/team/view/get_team_metadata.sh | 9 +++++++ 2 files changed, 45 insertions(+) create mode 100644 github/team/view/action.yaml create mode 100644 github/team/view/get_team_metadata.sh diff --git a/github/team/view/action.yaml b/github/team/view/action.yaml new file mode 100644 index 00000000..b1ce036e --- /dev/null +++ b/github/team/view/action.yaml @@ -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 + 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 }} diff --git a/github/team/view/get_team_metadata.sh b/github/team/view/get_team_metadata.sh new file mode 100644 index 00000000..15fabb38 --- /dev/null +++ b/github/team/view/get_team_metadata.sh @@ -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