2021-11-26 11:23:07 -05:00
|
|
|
name: Move pull requests asking for review to the relevant project
|
|
|
|
on:
|
2021-12-13 10:36:10 -05:00
|
|
|
pull_request_target:
|
2022-05-16 10:23:44 -04:00
|
|
|
types: [review_requested]
|
2021-12-13 10:36:10 -05:00
|
|
|
|
2021-11-26 11:23:07 -05:00
|
|
|
jobs:
|
|
|
|
add_design_pr_to_project:
|
|
|
|
name: Move PRs asking for design review to the design board
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: octokit/graphql-action@v2.x
|
|
|
|
id: find_team_members
|
|
|
|
with:
|
|
|
|
headers: '{"GraphQL-Features": "projects_next_graphql"}'
|
|
|
|
query: |
|
|
|
|
query find_team_members($team: String!) {
|
|
|
|
organization(login: "vector-im") {
|
|
|
|
team(slug: $team) {
|
|
|
|
members {
|
|
|
|
nodes {
|
|
|
|
login
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
team: ${{ env.TEAM }}
|
2021-11-29 12:22:53 -05:00
|
|
|
env:
|
|
|
|
TEAM: "design"
|
|
|
|
GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
|
2022-01-11 06:16:52 -05:00
|
|
|
- id: any_matching_reviewers
|
2021-11-26 11:23:07 -05:00
|
|
|
run: |
|
2022-01-11 06:16:52 -05:00
|
|
|
# Fetch requested reviewers, and people who are on the team
|
2021-11-26 11:23:07 -05:00
|
|
|
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
|
2022-01-11 06:16:52 -05:00
|
|
|
|
|
|
|
# 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
|
2022-01-11 08:38:19 -05:00
|
|
|
echo '${{ env.TEAM }}' | tee /tmp/team.txt
|
2022-01-11 06:16:52 -05:00
|
|
|
|
|
|
|
# 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
|
2023-04-12 06:48:28 -04:00
|
|
|
echo "match=true" >> $GITHUB_OUTPUT
|
2022-01-11 06:16:52 -05:00
|
|
|
elif [ $(join /tmp/team.txt /tmp/team_reviewers.txt | wc -l) != 0 ]; then
|
2023-04-12 06:48:28 -04:00
|
|
|
echo "match=true" >> $GITHUB_OUTPUT
|
2022-01-11 06:16:52 -05:00
|
|
|
else
|
2023-04-12 06:48:28 -04:00
|
|
|
echo "match=false" >> $GITHUB_OUTPUT
|
2021-11-26 11:23:07 -05:00
|
|
|
fi
|
2022-01-11 06:38:19 -05:00
|
|
|
env:
|
|
|
|
TEAM: "design"
|
2021-11-26 11:23:07 -05:00
|
|
|
- uses: octokit/graphql-action@v2.x
|
|
|
|
id: add_to_project
|
2022-01-11 06:16:52 -05:00
|
|
|
if: steps.any_matching_reviewers.outputs.match == 'true'
|
2021-11-26 11:23:07 -05:00
|
|
|
with:
|
|
|
|
headers: '{"GraphQL-Features": "projects_next_graphql"}'
|
|
|
|
query: |
|
2021-12-09 17:55:22 -05:00
|
|
|
mutation add_to_project($projectid:ID!, $contentid:ID!) {
|
2022-11-03 06:22:05 -04:00
|
|
|
addProjectV2ItemById(input: {projectId: $projectid contentId: $contentid}) {
|
|
|
|
item {
|
2021-11-26 11:23:07 -05:00
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
projectid: ${{ env.PROJECT_ID }}
|
|
|
|
contentid: ${{ github.event.pull_request.node_id }}
|
2021-11-29 12:22:53 -05:00
|
|
|
env:
|
2022-12-09 09:31:32 -05:00
|
|
|
PROJECT_ID: "PVT_kwDOAM0swc0sUA"
|
2021-11-29 12:22:53 -05:00
|
|
|
TEAM: "design"
|
|
|
|
GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
|
2022-01-18 08:12:27 -05:00
|
|
|
|
|
|
|
add_product_pr_to_project:
|
|
|
|
name: Move PRs asking for design review to the design board
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: octokit/graphql-action@v2.x
|
|
|
|
id: find_team_members
|
|
|
|
with:
|
|
|
|
headers: '{"GraphQL-Features": "projects_next_graphql"}'
|
|
|
|
query: |
|
|
|
|
query find_team_members($team: String!) {
|
|
|
|
organization(login: "vector-im") {
|
|
|
|
team(slug: $team) {
|
|
|
|
members {
|
|
|
|
nodes {
|
|
|
|
login
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
team: ${{ env.TEAM }}
|
|
|
|
env:
|
|
|
|
TEAM: "product"
|
|
|
|
GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
|
|
|
|
- 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
|
|
|
|
|
|
|
|
# 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
|
2023-04-12 06:48:28 -04:00
|
|
|
echo "match=true" >> $GITHUB_OUTPUT
|
2022-01-18 08:12:27 -05:00
|
|
|
elif [ $(join /tmp/team.txt /tmp/team_reviewers.txt | wc -l) != 0 ]; then
|
2023-04-12 06:48:28 -04:00
|
|
|
echo "match=true" >> $GITHUB_OUTPUT
|
2022-01-18 08:12:27 -05:00
|
|
|
else
|
2023-04-12 06:48:28 -04:00
|
|
|
echo "match=false" >> $GITHUB_OUTPUT
|
2022-01-18 08:12:27 -05:00
|
|
|
fi
|
|
|
|
env:
|
|
|
|
TEAM: "product"
|
|
|
|
- uses: octokit/graphql-action@v2.x
|
|
|
|
id: add_to_project
|
|
|
|
if: steps.any_matching_reviewers.outputs.match == 'true'
|
|
|
|
with:
|
|
|
|
headers: '{"GraphQL-Features": "projects_next_graphql"}'
|
|
|
|
query: |
|
|
|
|
mutation add_to_project($projectid:ID!, $contentid:ID!) {
|
2022-11-03 06:22:05 -04:00
|
|
|
addProjectV2ItemById(input: {projectId: $projectid contentId: $contentid}) {
|
|
|
|
item {
|
2022-01-18 08:12:27 -05:00
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
projectid: ${{ env.PROJECT_ID }}
|
|
|
|
contentid: ${{ github.event.pull_request.node_id }}
|
|
|
|
env:
|
2022-12-09 09:31:32 -05:00
|
|
|
PROJECT_ID: "PVT_kwDOAM0swc4AAg6N"
|
2022-01-18 08:12:27 -05:00
|
|
|
TEAM: "product"
|
|
|
|
GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
|