|
70 | 70 | PROJECT_ID: "PN_kwDOAM0swc0sUA" |
71 | 71 | TEAM: "design" |
72 | 72 | GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }} |
| 73 | + |
| 74 | + add_product_pr_to_project: |
| 75 | + name: Move PRs asking for design review to the design board |
| 76 | + runs-on: ubuntu-latest |
| 77 | + steps: |
| 78 | + |
| 79 | + id: find_team_members |
| 80 | + with: |
| 81 | + headers: '{"GraphQL-Features": "projects_next_graphql"}' |
| 82 | + query: | |
| 83 | + query find_team_members($team: String!) { |
| 84 | + organization(login: "vector-im") { |
| 85 | + team(slug: $team) { |
| 86 | + members { |
| 87 | + nodes { |
| 88 | + login |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + } |
| 93 | + } |
| 94 | + team: ${{ env.TEAM }} |
| 95 | + env: |
| 96 | + TEAM: "product" |
| 97 | + GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }} |
| 98 | + - id: any_matching_reviewers |
| 99 | + run: | |
| 100 | + # Fetch requested reviewers, and people who are on the team |
| 101 | + echo '${{ tojson(fromjson(steps.find_team_members.outputs.data).organization.team.members.nodes[*].login) }}' | tee /tmp/team_members.json |
| 102 | + echo '${{ tojson(github.event.pull_request.requested_reviewers[*].login) }}' | tee /tmp/reviewers.json |
| 103 | + jq --raw-output .[] < /tmp/team_members.json | sort | tee /tmp/team_members.txt |
| 104 | + jq --raw-output .[] < /tmp/reviewers.json | sort | tee /tmp/reviewers.txt |
| 105 | +
|
| 106 | + # Fetch requested team reviewers, and the name of the team |
| 107 | + echo '${{ tojson(github.event.pull_request.requested_teams[*].slug) }}' | tee /tmp/team_reviewers.json |
| 108 | + jq --raw-output .[] < /tmp/team_reviewers.json | sort | tee /tmp/team_reviewers.txt |
| 109 | + echo '${{ env.TEAM }}' | tee /tmp/team.txt |
| 110 | +
|
| 111 | + # If either a reviewer matches a team member, or a team matches our team, say "true" |
| 112 | + if [ $(join /tmp/team_members.txt /tmp/reviewers.txt | wc -l) != 0 ]; then |
| 113 | + echo "::set-output name=match::true" |
| 114 | + elif [ $(join /tmp/team.txt /tmp/team_reviewers.txt | wc -l) != 0 ]; then |
| 115 | + echo "::set-output name=match::true" |
| 116 | + else |
| 117 | + echo "::set-output name=match::false" |
| 118 | + fi |
| 119 | + env: |
| 120 | + TEAM: "product" |
| 121 | + |
| 122 | + id: add_to_project |
| 123 | + if: steps.any_matching_reviewers.outputs.match == 'true' |
| 124 | + with: |
| 125 | + headers: '{"GraphQL-Features": "projects_next_graphql"}' |
| 126 | + query: | |
| 127 | + mutation add_to_project($projectid:ID!, $contentid:ID!) { |
| 128 | + addProjectNextItem(input:{projectId:$projectid contentId:$contentid}) { |
| 129 | + projectNextItem { |
| 130 | + id |
| 131 | + } |
| 132 | + } |
| 133 | + } |
| 134 | + projectid: ${{ env.PROJECT_ID }} |
| 135 | + contentid: ${{ github.event.pull_request.node_id }} |
| 136 | + env: |
| 137 | + PROJECT_ID: "PN_kwDOAM0swc4AAg6N" |
| 138 | + TEAM: "product" |
| 139 | + GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }} |
0 commit comments