Created
December 12, 2022 23:17
-
-
Save lbussell/75d1302e06f8115083f420d783e931a8 to your computer and use it in GitHub Desktop.
Get .NET source-build release info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -euxo pipefail | |
query='query { | |
repository(name: \"source-build\", owner: \"dotnet\") { | |
discussions( | |
categoryId: \"DIC_kwDOA-dPNs4CBKbO\", | |
first: 10, | |
orderBy: {field: UPDATED_AT, direction: DESC} | |
) { | |
edges { | |
node { | |
id, title, body | |
} | |
} | |
} | |
} | |
}' | |
query="$(echo $query)" # remove newlines | |
discussions=$(curl -H 'Content-Type: application/json' \ | |
-H "Authorization: bearer $GH_TOKEN" \ | |
-X POST \ | |
-d "{ \"query\": \"$query\"}" https://api.github.com/graphql) | |
result="$(echo "${discussions}" | jq '.data.repository.discussions.edges[] | select(.node.title | contains("November") and contains("7.0")) | .node.body')" | |
# 1. 's,.*```json\(.*\)```.*,\1,' - Isolate the json | |
# 2. 's,\\r\\n,,g' - Remove the literal \r\n returned by the GitHub API | |
# 3. 's,\\,,g' - Remove the remaining `\`s to un-escape quotes | |
result="$(echo "$result" | sed 's,.*```json\(.*\)```.*,\1,; s,\\r\\n,,g; s,\\,,g')" | |
echo "$result" | jq |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment