Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions create-a-deployment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@
# https://docs.github.com/en/enterprise-cloud@latest/rest/deployments/deployments?apiVersion=2022-11-28#create-a-deployment
# POST /repos/{owner}/{repo}/deployments

ref=$1
# If the script is passed an argument $1 use that as the name
if [ -z "$1" ]
then
ref=${branch_name}
else
ref=$1
fi

json_file=tmp/deployment.json

json_file=tmp/create-a-deployment.json
jq -n \
--arg ref "${ref}" \
--arg environment "${default_environment_name}" \
Expand Down
12 changes: 5 additions & 7 deletions create-a-review-comment-for-a-pull-request.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/pulls#create-a-review-comment-for-a-pull-request
# https://docs.github.com/en/enterprise-cloud@latest/rest/pulls/comments?apiVersion=2022-11-28#create-a-review-comment-for-a-pull-request
# POST /repos/{owner}/{repo}/pulls/{pull_number}/comments


Expand All @@ -12,19 +12,18 @@ if [ -z "$1" ]
pull_number=$1
fi

json_file=tmp/create-a-review-comment-for-a-pull-request.json

# Beware. We are extracting the first commit in the pull request here.
# you may wan to do something else:
commit_id=$(./list-commits-on-a-pull-request.sh | jq -r '.[0].sha')

pull_request_review_body_comment="Great Stuff"
pull_request_review_body_comment="The Power pull request review body comment Stuff"
path="docs/new-file-for-pull-request-txt"
start_line=1
start_side=RIGHT
line=2
side=RIGHT

json_file=tmp/create-a-review-comment-for-a-pull-request.json
jq -n \
--arg body "${pull_request_review_body_comment}" \
--arg commit_id "$commit_id" \
Expand All @@ -43,9 +42,8 @@ jq -n \

GITHUB_TOKEN=${pr_approver_token}
curl -v ${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/${org}/${repo}/pulls/${pull_number}/comments --data @${json_file}


"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/pulls/${pull_number}/comments --data @${json_file}"

7 changes: 4 additions & 3 deletions create-a-review-for-a-pull-request.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/pulls#create-a-review-for-a-pull-request
# https://docs.github.com/en/enterprise-cloud@latest/rest/pulls/reviews?apiVersion=2022-11-28#create-a-review-for-a-pull-request
# POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews

# If the script is passed an argument $1 use that as the pull number
Expand All @@ -13,11 +13,11 @@ fi

event=${default_pr_event}

body="create-a-review-for-a-pull-request.sh ${event} Review for a pull request @${org}/${team_slug}. Demonstrates [create a review for a pull request](https://docs.github.com/en/rest/reference/pulls#create-a-review-for-a-pull-request)"
body="create-a-review-for-a-pull-request.sh ${event} Review for a pull request @${org}/${team_slug}. Demonstrates [create a review for a pull request](https://docs.github.com/en/enterprise-cloud@latest/rest/pulls/reviews?apiVersion=2022-11-28#create-a-review-for-a-pull-requestt)"


json_file="tmp/create-a-review-for-a-pull-request.json"

json_file="tmp/create-a-review-for-a-pull-request.json"
jq -n \
--arg event "$event" \
--arg body "$body" \
Expand All @@ -35,6 +35,7 @@ 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/${org}/${repo}/pulls/${pull_number}/reviews" --data @${json_file}
Expand Down
5 changes: 3 additions & 2 deletions create-approving-review-for-a-pull-request.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/pulls#create-a-review-for-a-pull-request
# https://docs.github.com/en/enterprise-cloud@latest/rest/pulls/reviews?apiVersion=2022-11-28#create-a-review-for-a-pull-request
# POST /repos/{owner}/{repo}/pulls/{pull_number}/reviews


Expand All @@ -21,6 +21,7 @@ jq -n \
GITHUB_TOKEN=${pr_approver_token}

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/${org}/${repo}/pulls/${pull_number}/reviews --data @${json_file}
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/pulls/${pull_number}/reviews" --data @${json_file}
8 changes: 4 additions & 4 deletions get-a-branch.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/repos#get-a-branch
# https://docs.github.com/en/enterprise-cloud@latest/rest/branches/branches?apiVersion=2022-11-28
# GET /repos/{owner}/{repo}/branches/{branch}

# If the script is passed an argument $1 use that as the name

if [ -z "$1" ]
then
branch=${base_branch}
Expand All @@ -13,8 +13,8 @@ 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/${org}/${repo}/branches/${branch}

"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/branches/${branch}"

4 changes: 3 additions & 1 deletion get-a-check-run.sh
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/checks/runs#get-a-check-run
# https://docs.github.com/en/enterprise-cloud@latest/rest/checks/runs?apiVersion=2022-11-28#get-a-check-run
# GET /repos/{owner}/{repo}/check-runs/{check_run_id}

# Check run id's can be seen at:
# https://github.com/{owner}/{repo}/pull/2/checks

if [ -z "$1" ]
then
check_run_id=$(./list-check-runs-for-a-git-reference.sh $target_branch | jq -r '.check_runs | last | .id')
Expand All @@ -16,3 +17,4 @@ curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/check-runs/${check_run_id}"

7 changes: 5 additions & 2 deletions get-a-code-scanning-analysis-for-a-repository.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
# https://docs.github.com/en/rest/code-scanning#get-a-code-scanning-analysis-for-a-repository
# GET /repos/{owner}/{repo}/code-scanning/analyses/{analysis_id}


# If the script is passed an argument $1 use that as the name
if [ -z "$1" ]
then
Expand All @@ -11,8 +12,10 @@ if [ -z "$1" ]
analysis_id=$1
fi

set -x

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}/code-scanning/analyses/${analysis_id}
"${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/code-scanning/analyses/${analysis_id}"

4 changes: 2 additions & 2 deletions get-a-code-scanning-default-setup-configuration.sh
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/code-scanning/code-scanning?apiVersion=2022-11-28#get-a-code-scanning-default-setup-configuration
# https://docs.github.com/en/enterprise-cloud@latest/rest/code-scanning/code-scanning?apiVersion=2022-11-28#get-a-code-scanning-default-setup-configuration
# GET /repos/{owner}/{repo}/code-scanning/default-setup


# If the script is passed an argument $1 use that as the name
if [ -z "$1" ]
then
repo=$repo
repo=${repo}
else
repo=$1
fi
Expand Down
4 changes: 2 additions & 2 deletions get-a-code-security-configuration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,9 @@
# GET /orgs/{org}/code-security/configurations/{configuration_id}


# If the script is passed an argument $1 use that as the name
if [ -z "$1" ]
then
org=$org
org=${org}
else
org=$1
fi
Expand All @@ -21,3 +20,4 @@ curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/orgs/${org}/code-security/configurations/${configuration_id}"

5 changes: 3 additions & 2 deletions get-a-codeql-database-for-a-repository.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/code-scanning#get-a-codeql-database-for-a-repository
# https://docs.github.com/en/enterprise-cloud@latest/rest/code-scanning/code-scanning?apiVersion=2022-11-28#get-a-codeql-database-for-a-repository
# GET /repos/{owner}/{repo}/code-scanning/codeql/databases/{language}


Expand All @@ -16,4 +16,5 @@ fi
curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/code-scanning/codeql/databases/${language}
"${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/code-scanning/codeql/databases/${language}"

9 changes: 6 additions & 3 deletions get-a-codespaces-for-authenticated-user.sh
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/codespaces/codespaces#get-a-codespace-for-the-authenticated-user
# https://docs.github.com/en/enterprise-cloud@latest/rest/codespaces/codespaces?apiVersion=2022-11-28#get-a-codespace-for-the-authenticated-user
# GET /user/codespaces/{codespace_name}

# If the script is passed an argument $1 use that as the codespace name

if [ -z "$1" ]
then
codespace_name=$(./list-codespaces-for-authenticated-user.sh | jq '.codespaces[0].name')
else
codespace_name=$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}/user/codespaces/${codespace_name}
"${GITHUB_API_BASE_URL}/user/codespaces/${codespace_name}"

2 changes: 1 addition & 1 deletion get-a-commit.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/commits/commits?apiVersion=2022-11-28#get-a-commit
# https://docs.github.com/en/enterprise-cloud@latest/rest/commits/commits?apiVersion=2022-11-28#get-a-commit
# GET /repos/{owner}/{repo}/commits/{ref}

ref=$1
Expand Down
9 changes: 6 additions & 3 deletions get-a-delivery-for-a-repository-webhook.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,24 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/repos#get-a-delivery-for-a-repository-webhook
# https://docs.github.com/en/enterprise-cloud@latest/rest/repos/webhooks?apiVersion=2022-11-28#get-a-delivery-for-a-repository-webhook
# GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}


# If the script is passed an argument $1 use that as the hook_id
if [ -z "$1" ]
then
# we get the first delivery_id the list repo here:
hook_id=$(./list-repo-webhooks.sh | jq -r '.[0] .id')
echo "hook_id: $hook_id"
delivery_id=$(./list-deliveries-for-repository-webhook.sh | jq -r '.[0] .id')
else
hook_id=$1
delivery_id=$2
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/${org}/${repo}/hooks/${hook_id}/deliveries/${delivery_id}
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/hooks/${hook_id}/deliveries/${delivery_id}"

7 changes: 5 additions & 2 deletions get-a-delivery-for-a-webhook.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/repos#get-a-delivery-for-a-repository-webhook
# https://docs.github.com/en/enterprise-cloud@latest/rest/repos/webhooks?apiVersion=2022-11-28#get-a-delivery-for-a-repository-webhook
# GET /repos/{owner}/{repo}/hooks/{hook_id}/deliveries/{delivery_id}


# If the script is passed an argument $1 use that as the hook_id
if [ -z "$1" ]
then
Expand All @@ -16,6 +17,8 @@ if [ -z "$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/${org}/${repo}/hooks/${hook_id}/deliveries/${delivery_id}
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/hooks/${hook_id}/deliveries/${delivery_id}"

7 changes: 5 additions & 2 deletions get-a-deployment.sh
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/repos#get-a-deployment
# https://docs.github.com/en/enterprise-cloud@latest/rest/deployments/deployments?apiVersion=2022-11-28#get-a-deployment
# GET /repos/{owner}/{repo}/deployments/{deployment_id}


if [ -z "$1" ]
then
deployment_id=${default_deployment_id}
Expand All @@ -11,6 +12,8 @@ if [ -z "$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/${org}/${repo}/deployments/${deployment_id}
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/deployments/${deployment_id}"

3 changes: 1 addition & 2 deletions get-a-diff-of-the-dependencies-between-commits.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/dependency-graph/dependency-review?apiVersion=2022-11-28#get-a-diff-of-the-dependencies-between-commits
# https://docs.github.com/en/enterprise-cloud@latest/rest/dependency-graph/dependency-review?apiVersion=2022-11-28#get-a-diff-of-the-dependencies-between-commits
# GET /repos/{owner}/{repo}/dependency-graph/compare/{basehead}


Expand All @@ -21,4 +21,3 @@ curl ${curl_custom_flags} \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
"${GITHUB_API_BASE_URL}/repos/${owner}/${repo}/dependency-graph/compare/${basehead}"

9 changes: 0 additions & 9 deletions get-notifications.sh

This file was deleted.

8 changes: 5 additions & 3 deletions get-release-tarball.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/repos#get-a-release-asset
# GET /repos/:owner/:repo/releases/assets/:asset_id
# https://docs.github.com/en/enterprise-cloud@latest/rest/releases/assets?apiVersion=2022-11-28#get-a-release-asset
# GET /repos/{owner}/{repo}/releases/assets/{asset_id}


release_tarball_name=$(./list-releases.sh | jq -r '.[] | .tarball_url')

Expand All @@ -11,4 +12,5 @@ curl ${curl_custom_flags} \
-L \
-H "Accept: application/vnd.github.v3+json" \
-H "Authorization: Bearer ${GITHUB_TOKEN}" \
${release_tarball_name} --output ${output_file}
"${release_tarball_name}" --output ${output_file}

7 changes: 5 additions & 2 deletions get-repository-clones.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/repos#get-repository-clones
# https://docs.github.com/en/enterprise-cloud@latest/rest/metrics/traffic?apiVersion=2022-11-28#get-repository-clones
# GET /repos/{owner}/{repo}/traffic/clones


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/${org}/${repo}/traffic/clones
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/traffic/clones"

7 changes: 5 additions & 2 deletions get-repository-page-views.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
. ./.gh-api-examples.conf

# https://docs.github.com/en/rest/reference/repos#get-page-views
# https://docs.github.com/en/enterprise-cloud@latest/rest/metrics/traffic?apiVersion=2022-11-28#get-page-views
# GET /repos/{owner}/{repo}/traffic/views


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/${org}/${repo}/traffic/views
"${GITHUB_API_BASE_URL}/repos/${org}/${repo}/traffic/views"

Loading