Skip to content

Instantly share code, notes, and snippets.

@metacoma
Created January 5, 2021 12:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save metacoma/c5724a236574da2f6ae2680b28a8be75 to your computer and use it in GitHub Desktop.
Save metacoma/c5724a236574da2f6ae2680b28a8be75 to your computer and use it in GitHub Desktop.
pr check prototype
#!/bin/sh
OWNER=mgm-sandbox
REPO=magma
PR_ID=4
generate_pr_status_gql() {
cat<<EOF
{
repository(owner: "$OWNER", name: "$REPO") {
pullRequest(number: 4) {
url
labels(last: 100) {
nodes {
name
}
}
reviews(last: 1) {
totalCount
nodes {
state
}
}
reviewDecision
}
}
}
EOF
}
generate_pr_status_gql $OWNER $REPO | gh api graphql -f query="`cat`"
gh pr checks $PR_ID -R $OWNER/$REPO
@metacoma
Copy link
Author

metacoma commented Jan 5, 2021

example output:

{
  "data": {
    "repository": {
      "pullRequest": {
        "url": "https://github.com/mgm-sandbox/magma/pull/4",
        "labels": {
          "nodes": [
            {
              "name": "ready-for-merge"
            }
          ]
        },
        "reviews": {
          "totalCount": 3,
          "nodes": [
            {
              "state": "APPROVED"
            }
          ]
        },
        "reviewDecision": "APPROVED"
      }
    }
  }
}

All checks were successful
0 failing, 3 successful, and 0 pending checks

✓ continuous-integration/circle https://circleci.com
✓ continuous-integration/integration-test https://jenkins.mgm.metacoma.io
✓ continuous-integration/jenkins https://jenkins.mgm.metacoma.io

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment