In review-request action, treat requested_teams as an array (#20474)

pull/20477/head
Andy Balaam 2022-01-11 11:16:52 +00:00 committed by GitHub
parent 2d548d1179
commit c27cdcf849
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 11 deletions

View File

@ -28,26 +28,30 @@ jobs:
env:
TEAM: "design"
GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
- id: any_reviewers_in_the_team
- id: any_matching_reviewers
run: |
# Fetch requested reviewers, and people who are on the team
echo '${{ tojson(fromjson(steps.find_team_members.outputs.data).organization.team.members.nodes[*].login) }}' | tee /tmp/team_members.json
echo '${{ tojson(github.event.pull_request.requested_reviewers[*].login) }}' | tee /tmp/reviewers.json
jq --raw-output .[] < /tmp/team_members.json | sort | tee /tmp/team_members.txt
jq --raw-output .[] < /tmp/reviewers.json | sort | tee /tmp/reviewers.txt
if [ $(join /tmp/team_members.txt /tmp/reviewers.txt | wc -l) = 0 ]; then
echo "::set-output name=match::false"
else
# Fetch requested team reviewers, and the name of the team
echo '${{ tojson(github.event.pull_request.requested_teams[*].slug) }}' | tee /tmp/team_reviewers.json
jq --raw-output .[] < /tmp/team_reviewers.json | sort | tee /tmp/team_reviewers.txt
echo '${{ env.TEAM }}$' | tee /tmp/team.txt
# If either a reviewer matches a team member, or a team matches our team, say "true"
if [ $(join /tmp/team_members.txt /tmp/reviewers.txt | wc -l) != 0 ]; then
echo "::set-output name=match::true"
elif [ $(join /tmp/team.txt /tmp/team_reviewers.txt | wc -l) != 0 ]; then
echo "::set-output name=match::true"
else
echo "::set-output name=match::false"
fi
- id: print_requested_teams_slug
run: |
echo 'github.event.pull_request.requested_teams.slug = ${{ github.event.pull_request.requested_teams.slug }}'
echo 'github.event.pull_request.requested_reviewers = ${{ github.event.pull_request.requested_reviewers }}'
- uses: octokit/graphql-action@v2.x
id: add_to_project
if: >
(steps.any_reviewers_in_the_team.outputs.match == 'true') ||
(github.event.pull_request.requested_teams.slug == env.TEAM)
if: steps.any_matching_reviewers.outputs.match == 'true'
with:
headers: '{"GraphQL-Features": "projects_next_graphql"}'
query: |