#!/usr/bin/env bash # https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line TOKEN= prs() { if [ -n "$1" ]; then after=", after: \"$1\"" fi QUERY=$(cat <<-EOF { repository(name: "nixpkgs", owner: "NixOS") { pullRequests(first: 100, states: OPEN$after) { nodes { url } pageInfo { hasNextPage endCursor } } } } EOF ) DATA=$(jq -n --arg query "$(echo "$QUERY")" '{ query : $query }') result=$(curl -sS -H "Authorization: token $TOKEN" -d "$DATA" https://api.github.com/graphql | jq '.data.repository.pullRequests') echo "$result" | jq -r '.nodes[].url' if [ "$(echo "$result" | jq -r '.pageInfo.hasNextPage')" = true ]; then prs "$(echo "$result" | jq -r '.pageInfo.endCursor')" fi } prs