diff --git a/graphql-list-repository-release-assets.sh b/graphql-list-repository-release-assets.sh new file mode 100755 index 00000000..8b49b2c7 --- /dev/null +++ b/graphql-list-repository-release-assets.sh @@ -0,0 +1,55 @@ +. ./.gh-api-examples.conf + +# https://docs.github.com/en/graphql/reference/objects#repository + +read -r -d '' graphql_script <<- EOF +{ +search(type: REPOSITORY, query: "repo:$org/$repo", first: 1) { + nodes { + ... on Repository { + id + databaseId + nameWithOwner + createdAt + isSecurityPolicyEnabled + isArchived + rulesets(first: 10) { + totalCount + nodes { + name + target + enforcement + } + } + releases(last: 1) { + totalCount + nodes { + tagName + releaseAssets(first: 100) { + totalCount + nodes { + name + size + createdAt + updatedAt + downloadUrl + contentType + downloadCount + uploadedBy { name } + } + } + } + } + } + } + } +} +EOF + +graphql_script="$(echo ${graphql_script//\"/\\\"})" + +curl ${curl_custom_flags} \ + -H "Accept: application/vnd.github.v3+json" \ + -H 'Accept: application/vnd.github.audit-log-preview+json' \ + -H "Authorization: Bearer ${GITHUB_TOKEN}" \ + ${GITHUB_APIV4_BASE_URL} -d "{ \"query\": \"$graphql_script\"}"