Last active
July 13, 2021 02:08
-
-
Save horothesun/cb799c61a983a17c4aff68d9d413c4bf to your computer and use it in GitHub Desktop.
github_billing
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
# IMPORTANT: GITHUB_TOKEN with "Update ALL user data" permission | |
# | |
# Dependencies: | |
# - curl | |
# - jq | |
# | |
# Run: | |
# GITHUB_TOKEN=<token> GITHUB_USER=<username> ./github_billing.sh | |
# | |
[ -z "$GITHUB_TOKEN" ] && echo "Error: GITHUB_TOKEN must be defined" && exit 10 | |
[ -z "$GITHUB_USER" ] && echo "Error: GITHUB_USER must be defined" && exit 11 | |
ACTIONS_JSON=`curl --silent\ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/users/$GITHUB_USER/settings/billing/actions` | |
PACKAGES_JSON=`curl --silent\ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/users/$GITHUB_USER/settings/billing/packages` | |
SHARED_STORAGE_JSON=`curl --silent\ | |
-H "Authorization: token $GITHUB_TOKEN" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
https://api.github.com/users/$GITHUB_USER/settings/billing/shared-storage` | |
RESULT_JSON=""" | |
{ | |
\"actions\": $ACTIONS_JSON, | |
\"packages\": $PACKAGES_JSON, | |
\"shared_storage\": $SHARED_STORAGE_JSON | |
} | |
""" | |
echo $RESULT_JSON | jq -M '.' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment