ghコマンド を用いて Organization の課金額を取得する方法

結論

$ gh api -H "Accept: application/vnd.github+json" /orgs/ORGANIZATION_NAME/settings/billing/actions

注意点

gh を認証した際に admin:org スコープの権限が付与されていないと以下のようなエラーが出ます。

$ gh api -H "Accept: application/vnd.github+json" /orgs/ORGANIZATION_NAME/settings/billing/actions
{
  "message": "Not Found",
  "documentation_url": "https://docs.github.com/rest/reference/billing#get-github-actions-billing-for-an-organization"
}
gh: Not Found (HTTP 404)
gh: This API operation needs the "admin:org" scope. To request it, run:  gh auth refresh -h github.com -s admin:org

ドキュメント

この記事よりも公式ドキュメントがいろいろ詳しいです。

https://docs.github.com/ja/rest/billing#get-github-actions-billing-for-an-organization

Powered by はてなブログ