-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #221 from gm3dmo/issue220
Adding scripts to summarize check suite/run to csv close #220
- Loading branch information
Showing
6 changed files
with
87 additions
and
18 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
. ./.gh-api-examples.conf | ||
|
||
# https://docs.github.com/en/enterprise-cloud@latest/rest/checks/runs?apiVersion=2022-11-28#list-check-runs-for-a-git-reference | ||
# GET /repos/{owner}/{repo}/commits/{ref}/check-runs | ||
|
||
branch_for_ref=${branch_name} | ||
|
||
# If the script is passed an argument $1 use that as the name | ||
if [ -z "$1" ] | ||
then | ||
ref=${branch_for_ref} | ||
else | ||
ref=$1 | ||
fi | ||
|
||
response_file=tmp/list-check-runs-for-a-git-reference.json | ||
|
||
curl ${curl_custom_flags} \ | ||
-H "X-GitHub-Api-Version: ${github_api_version}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
"${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/commits/${ref}/check-runs" > ${response_file} | ||
|
||
jq -r ' | ||
["Cnt","Check Suite ID","Check Run ID","Name","Head SHA","App Name"], | ||
( .check_runs | to_entries[] | | ||
[ ( .key | tonumber + 1 | tostring ), | ||
( .value.check_suite.id | tostring ), | ||
( .value.id | tostring ), | ||
.value.name, | ||
.value.head_sha, | ||
.value.app.name ] ) | ||
| @csv' ${response_file} | csvlook --no-inference | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,20 @@ | ||
. ./.gh-api-examples.conf | ||
|
||
# https://docs.github.com/en/rest/checks/runs?apiVersion=2022-11-28#list-check-runs-for-a-git-reference | ||
# https://docs.github.com/en/enterprise-cloud@latest/rest/checks/runs?apiVersion=2022-11-28#list-check-runs-for-a-git-reference | ||
# GET /repos/{owner}/{repo}/commits/{ref}/check-runs | ||
|
||
branch_for_ref=${branch_name} | ||
|
||
# If the script is passed an argument $1 use that as the name | ||
if [ -z "$1" ] | ||
then | ||
ref=${branch_for_ref} | ||
ref=${branch_name} | ||
else | ||
ref=$1 | ||
fi | ||
|
||
|
||
curl ${curl_custom_flags} \ | ||
-H "X-GitHub-Api-Version: ${github_api_version}" \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
"${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/commits/${ref}/check-runs" | ||
|
||
|
||
# use the jq below to get just the id out: | ||
# | jq -r '.check_runs | last | .id' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
. ./.gh-api-examples.conf | ||
|
||
# https://docs.github.com/en/enterprise-cloud@latest/rest/checks/suites?apiVersion=2022-11-28#list-check-suites-for-a-git-reference | ||
# GET /repos/{owner}/{repo}/commits/{ref}/check-suites | ||
|
||
|
||
if [ -z "$1" ] | ||
then | ||
ref=$(curl --silent -H "Authorization: Bearer ${GITHUB_TOKEN}" ${GITHUB_API_BASE_URL}/repos/${org}/${repo}/git/refs/heads/${branch_name}| jq -r '.object.sha') | ||
else | ||
ref=$1 | ||
fi | ||
|
||
response_file=tmp/list-check-suites-for-a-git-reference.json | ||
|
||
curl ${curl_custom_flags} \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/commits/${ref}/check-suites" > ${response_file} | ||
|
||
jq -r ' | ||
["Cnt","ID","Head Branch","Head SHA","Status","PR","App Name","Created At","Updated At"], | ||
( .check_suites | to_entries[] | | ||
[ ( .key | tonumber + 1 | tostring ), | ||
( .value.id | tostring ), | ||
.value.head_branch, | ||
.value.head_sha, | ||
.value.status, | ||
( .value.pull_requests | map(.number | tostring) | join(";") ), | ||
.value.app.name, | ||
.value.created_at, | ||
.value.updated_at ] ) | ||
| @csv' tmp/response.json | csvlook --no-inference |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,19 @@ | ||
. ./.gh-api-examples.conf | ||
|
||
# https://docs.github.com/en/rest/checks/suites#list-check-suites-for-a-git-reference | ||
# https://docs.github.com/en/enterprise-cloud@latest/rest/checks/suites?apiVersion=2022-11-28#list-check-suites-for-a-git-reference | ||
# GET /repos/{owner}/{repo}/commits/{ref}/check-suites | ||
|
||
ref=$1 | ||
|
||
if [ -z "$1" ] | ||
then | ||
ref=$(curl --silent -H "Authorization: Bearer ${GITHUB_TOKEN}" ${GITHUB_API_BASE_URL}/repos/${org}/${repo}/git/refs/heads/${branch_name}| jq -r '.object.sha') | ||
else | ||
ref=$1 | ||
fi | ||
|
||
|
||
curl ${curl_custom_flags} \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
-H "Authorization: Bearer ${GITHUB_TOKEN}" \ | ||
${GITHUB_API_BASE_URL}/repos/${org}/${repo}/commits/${ref}/check-suites | ||
|
||
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/commits/${ref}/check-suites" | ||
|
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
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