2021-11-26 19:23:07 +03:00
|
|
|
name: Move pull requests asking for review to the relevant project
|
|
|
|
on:
|
2021-12-13 18:36:10 +03:00
|
|
|
pull_request_target:
|
2021-11-26 19:23:07 +03:00
|
|
|
types: [review_requested]
|
2021-12-13 18:36:10 +03:00
|
|
|
|
2021-11-26 19:23:07 +03: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 20:22:53 +03:00
|
|
|
env:
|
|
|
|
TEAM: "design"
|
|
|
|
GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
|
2021-11-26 19:23:07 +03:00
|
|
|
- id: any_reviewers_in_the_team
|
|
|
|
run: |
|
|
|
|
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
|
|
|
|
echo "::set-output name=match::true"
|
|
|
|
fi
|
2022-01-11 13:49:07 +03:00
|
|
|
- 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 }}'
|
2021-11-26 19:23:07 +03:00
|
|
|
- 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)
|
|
|
|
with:
|
|
|
|
headers: '{"GraphQL-Features": "projects_next_graphql"}'
|
|
|
|
query: |
|
2021-12-10 01:55:22 +03:00
|
|
|
mutation add_to_project($projectid:ID!, $contentid:ID!) {
|
2021-11-26 19:23:07 +03:00
|
|
|
addProjectNextItem(input:{projectId:$projectid contentId:$contentid}) {
|
|
|
|
projectNextItem {
|
|
|
|
id
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
projectid: ${{ env.PROJECT_ID }}
|
|
|
|
contentid: ${{ github.event.pull_request.node_id }}
|
2021-11-29 20:22:53 +03:00
|
|
|
env:
|
|
|
|
PROJECT_ID: "PN_kwDOAM0swc0sUA"
|
|
|
|
TEAM: "design"
|
|
|
|
GITHUB_TOKEN: ${{ secrets.ELEMENT_BOT_TOKEN }}
|