Add an emoji for the channel reviewers
Some repositories might have reviews asked in several channels. Currently the 🟢 (approved) emoji is put in the message as soon as the PR has enough reviewers with respect to the repo branch rule protection. It could be convenient to reflect in the channel the review was done by someone belonging to the channel itself. Somehow relates to #38
I tried to fix this issue. I didn't manage to make it fully work but I'll write down my notes here in case someone wants to have a look at this.
My idea was to associate the slack channel with a GitHub team, providing one more parameter to slapr: SLAPR_GITHUB_TEAM_NAME. Slapr would then check if the reviewer is part of the GitHub team (and then belongs to the slack channel) to trigger the emoji.
Making sure a GitHub user belongs to a GitHub can be done using the REST API or using this graphql query:
❯ gh api graphql --paginate -f query='{organization(login: "DataDog") {teams(first: 100, userLogins: ["alopezz"]) { edges {node {name}}}}}' | jq -c -r '.data.organization.teams.edges[].node.name'
Dev
agent-integrations
I tried to put that in place in integrations-core, conditionally running the slapr job if and only if the reviewer belongs to the given team. The problem is that the token I used (${{ secrets.GITHUB_TOKEN }}) does not have the right permissions to get this information from the DD org, even with permissions: read-all. We need a Oauth access token with the read:org scope