Skip to content

Instantly share code, notes, and snippets.

@joelanford
Last active May 6, 2021 18:13
Show Gist options
  • Save joelanford/918d34426eb50751ee0ac37b815e24f0 to your computer and use it in GitHub Desktop.
Save joelanford/918d34426eb50751ee0ac37b815e24f0 to your computer and use it in GitHub Desktop.
OLMs Ready To Review PRs
#!/usr/bin/env bash
gql='query {
operatorLifecycleManager: repository(owner:"operator-framework", name:"operator-lifecycle-manager") {
...repoPullRequests
}
operatorRegistry: repository(owner:"operator-framework", name:"operator-registry") {
...repoPullRequests
}
kubectlOperator: repository(owner:"operator-framework", name:"kubectl-operator") {
...repoPullRequests
}
api: repository(owner:"operator-framework", name:"api") {
...repoPullRequests
}
enhancements: repository(owner:"operator-framework", name:"enhancements") {
...repoPullRequests
}
}
fragment repoPullRequests on Repository {
name
pullRequests(first: 50, states: OPEN) {
nodes {
title
labels(first: 20){
nodes {
name
}
}
author {
login
}
commits(last:1) {
nodes {
commit{
status{
state
}
}
}
}
updatedAt
mergeable
url
}
}
}'
jqquery='
[
.data[].pullRequests.nodes[] |
select(
.mergeable == "MERGEABLE" and
.commits.nodes[0].commit.status.state == "PENDING" and
(.author.login as $author | $maintainers | any(. == $author)) and
([.labels.nodes[].name] | contains(["do-not-merge"]) | not) and
([.labels.nodes[].name] | (any(. == "lgtm") and any(. == "approved")) | not)
)
] |
sort_by(.updatedAt) | reverse | .[] |
"@"+.author.login + "\t" + .title + "\n\t" + .url +"\n"
'
maintainers=$(curl -s https://raw.githubusercontent.com/operator-framework/operator-lifecycle-manager/master/OWNERS | yq e -j '.' - | jq '.approvers + .reviewers | unique')
QUERY=$(jq -n --arg q "$gql" '{ query: $q }')
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Authorization: bearer $TOKEN" \
--data "$QUERY" \
https://api.github.com/graphql | jq -r --argjson maintainers "${maintainers}" "${jqquery}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment