Skip to main content
我们经常发布文档更新,此页面的翻译可能仍在进行中。 有关最新信息,请访问英语文档
REST API 现已经过版本控制。 有关详细信息,请参阅“关于 API 版本控制”。

GitHub Actions 必需工作流

使用 REST API 在 GitHub Actions 中访问和配置组织中的必需工作流。

List required workflows

适用于 GitHub Apps

List all required workflows in an organization.

You must authenticate using an access token with the read:org scope to use this endpoint.

For more information, see "Required Workflows."

“List required workflows”的参数

标头
名称, 类型, 说明
acceptstring

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
orgstring必选

The organization name. The name is not case sensitive.

查询参数
名称, 类型, 说明
per_pageinteger

The number of results per page (max 100).

默认: 30

pageinteger

Page number of the results to fetch.

默认: 1

“List required workflows”的 HTTP 响应状态代码

状态代码说明
200

OK

“List required workflows”的示例代码

get/orgs/{org}/actions/required_workflows
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/actions/required_workflows

Response

Status: 200
{ "total_count": 2, "required_workflows": [ { "id": 30433642, "name": "Required CI", "path": ".github/workflows/ci.yml", "scope": "selected", "ref": "refs/head/main", "state": "active", "selected_repositories_url": "https://api.github.com/organizations/org/actions/required_workflows/1/repositories", "created_at": "2020-01-22T19:33:08Z", "updated_at": "2020-01-22T19:33:08Z", "repository": { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World", "owner": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "private": false, "html_url": "https://github.com/octocat/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octocat/Hello-World", "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads", "events_url": "https://api.github.com/repos/octocat/Hello-World/events", "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octocat/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages", "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}", "ssh_url": "git@github.com:octocat/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags", "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams", "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks" } }, { "id": 30433643, "name": "Required Linter", "path": ".github/workflows/lint.yml", "scope": "all", "ref": "refs/head/main", "state": "active", "created_at": "2020-01-22T19:33:08Z", "updated_at": "2020-01-22T19:33:08Z", "repository": { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World", "owner": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "private": false, "html_url": "https://github.com/octocat/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octocat/Hello-World", "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads", "events_url": "https://api.github.com/repos/octocat/Hello-World/events", "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octocat/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages", "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}", "ssh_url": "git@github.com:octocat/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags", "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams", "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks" } } ] }

Create a required workflow

适用于 GitHub Apps

Create a required workflow in an organization.

You must authenticate using an access token with the admin:org scope to use this endpoint.

For more information, see "Required Workflows."

“Create a required workflow”的参数

标头
名称, 类型, 说明
acceptstring

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
orgstring必选

The organization name. The name is not case sensitive.

正文参数
名称, 类型, 说明
workflow_file_pathstring必选

Path of the workflow file to be configured as a required workflow.

repository_idstring必选

The ID of the repository that contains the workflow file.

scopestring

Enable the required workflow for all repositories or selected repositories in the organization.

默认: all

可以是以下选项之一: selected, all

selected_repository_idsarray of integers

A list of repository IDs where you want to enable the required workflow. You can only provide a list of repository ids when the scope is set to selected.

“Create a required workflow”的 HTTP 响应状态代码

状态代码说明
201

Created

422

Validation failed, or the endpoint has been spammed.

“Create a required workflow”的示例代码

post/orgs/{org}/actions/required_workflows
curl -L \ -X POST \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/actions/required_workflows \ -d '{"workflow_file_path":".github/workflows/ci.yaml","repository_id":53,"scope":"selected","selected_repository_ids":[32,91]}'

Response

Status: 201
{ "id": 30433642, "name": "Required CI", "path": ".github/workflows/ci.yml", "scope": "selected", "ref": "refs/head/main", "state": "active", "selected_repositories_url": "https://api.github.com/orgs/octo-org/actions/required_workflows/1/repositories", "created_at": "2020-01-22T19:33:08Z", "updated_at": "2020-01-22T19:33:08Z", "repository": { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World", "owner": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "private": false, "html_url": "https://github.com/octocat/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octocat/Hello-World", "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads", "events_url": "https://api.github.com/repos/octocat/Hello-World/events", "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octocat/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages", "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}", "ssh_url": "git@github.com:octocat/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags", "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams", "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks" } }

Get a required workflow

适用于 GitHub Apps

Get a required workflow configured in an organization.

You must authenticate using an access token with the read:org scope to use this endpoint.

For more information, see "Required Workflows."

“Get a required workflow”的参数

标头
名称, 类型, 说明
acceptstring

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
orgstring必选

The organization name. The name is not case sensitive.

required_workflow_idinteger必选

The unique identifier of the required workflow.

“Get a required workflow”的 HTTP 响应状态代码

状态代码说明
200

OK

“Get a required workflow”的示例代码

get/orgs/{org}/actions/required_workflows/{required_workflow_id}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/actions/required_workflows/REQUIRED_WORKFLOW_ID

Response

Status: 200
{ "id": 30433642, "name": "Required CI", "path": ".github/workflows/ci.yml", "scope": "selected", "ref": "refs/head/main", "state": "active", "selected_repositories_url": "https://api.github.com/orgs/octo-org/actions/required_workflows/1/repositories", "created_at": "2020-01-22T19:33:08Z", "updated_at": "2020-01-22T19:33:08Z", "repository": { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World", "owner": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "private": false, "html_url": "https://github.com/octocat/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octocat/Hello-World", "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads", "events_url": "https://api.github.com/repos/octocat/Hello-World/events", "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octocat/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages", "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}", "ssh_url": "git@github.com:octocat/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags", "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams", "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks" } }

Update a required workflow

适用于 GitHub Apps

Update a required workflow in an organization.

You must authenticate using an access token with the admin:org scope to use this endpoint.

For more information, see "Required Workflows."

“Update a required workflow”的参数

标头
名称, 类型, 说明
acceptstring

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
orgstring必选

The organization name. The name is not case sensitive.

required_workflow_idinteger必选

The unique identifier of the required workflow.

正文参数
名称, 类型, 说明
workflow_file_pathstring

Path of the workflow file to be configured as a required workflow.

repository_idstring

The ID of the repository that contains the workflow file.

scopestring

Enable the required workflow for all repositories or selected repositories in the organization.

默认: all

可以是以下选项之一: selected, all

selected_repository_idsarray of integers

A list of repository IDs where you want to enable the required workflow. A list of repository IDs where you want to enable the required workflow. You can only provide a list of repository ids when the scope is set to selected.

“Update a required workflow”的 HTTP 响应状态代码

状态代码说明
200

OK

422

Validation failed, or the endpoint has been spammed.

“Update a required workflow”的示例代码

patch/orgs/{org}/actions/required_workflows/{required_workflow_id}
curl -L \ -X PATCH \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/actions/required_workflows/REQUIRED_WORKFLOW_ID \ -d '{"workflow_file_path":".github/workflows/ci.yaml","repository_id":53,"scope":"selected","selected_repository_ids":[32,91]}'

Response

Status: 200
{ "id": 30433642, "name": "Required CI", "path": ".github/workflows/ci.yml", "scope": "selected", "ref": "refs/head/main", "state": "active", "selected_repositories_url": "https://api.github.com/orgs/octo-org/actions/required_workflows/1/repositories", "created_at": "2020-01-22T19:33:08Z", "updated_at": "2020-01-22T19:33:08Z", "repository": { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World", "owner": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "private": false, "html_url": "https://github.com/octocat/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octocat/Hello-World", "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads", "events_url": "https://api.github.com/repos/octocat/Hello-World/events", "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octocat/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages", "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}", "ssh_url": "git@github.com:octocat/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags", "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams", "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", "hooks_url": "http://api.github.com/repos/octocat/Hello-World/hooks" } }

Delete a required workflow

适用于 GitHub Apps

Deletes a required workflow configured in an organization.

You must authenticate using an access token with the admin:org scope to use this endpoint.

For more information, see "Required Workflows."

“Delete a required workflow”的参数

标头
名称, 类型, 说明
acceptstring

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
orgstring必选

The organization name. The name is not case sensitive.

required_workflow_idinteger必选

The unique identifier of the required workflow.

“Delete a required workflow”的 HTTP 响应状态代码

状态代码说明
204

No Content

“Delete a required workflow”的示例代码

delete/orgs/{org}/actions/required_workflows/{required_workflow_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/actions/required_workflows/REQUIRED_WORKFLOW_ID

Response

Status: 204

List selected repositories for a required workflow

适用于 GitHub Apps

Lists the selected repositories that are configured for a required workflow in an organization. To use this endpoint, the required workflow must be configured to run on selected repositories.

You must authenticate using an access token with the read:org scope to use this endpoint. GitHub Apps must have the administration organization permission to use this endpoint.

For more information, see "Required Workflows."

“List selected repositories for a required workflow”的参数

标头
名称, 类型, 说明
acceptstring

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
orgstring必选

The organization name. The name is not case sensitive.

required_workflow_idinteger必选

The unique identifier of the required workflow.

“List selected repositories for a required workflow”的 HTTP 响应状态代码

状态代码说明
200

Success

404

Resource Not Found

“List selected repositories for a required workflow”的示例代码

get/orgs/{org}/actions/required_workflows/{required_workflow_id}/repositories
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/actions/required_workflows/REQUIRED_WORKFLOW_ID/repositories

Success

Status: 200
{ "total_count": 1, "repositories": [ { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octocat/Hello-World", "owner": { "login": "octocat", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octocat_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octocat", "html_url": "https://github.com/octocat", "followers_url": "https://api.github.com/users/octocat/followers", "following_url": "https://api.github.com/users/octocat/following{/other_user}", "gists_url": "https://api.github.com/users/octocat/gists{/gist_id}", "starred_url": "https://api.github.com/users/octocat/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octocat/subscriptions", "organizations_url": "https://api.github.com/users/octocat/orgs", "repos_url": "https://api.github.com/users/octocat/repos", "events_url": "https://api.github.com/users/octocat/events{/privacy}", "received_events_url": "https://api.github.com/users/octocat/received_events", "type": "User", "site_admin": false }, "private": false, "html_url": "https://github.com/octocat/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octocat/Hello-World", "archive_url": "https://api.github.com/repos/octocat/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octocat/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octocat/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octocat/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octocat/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octocat/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octocat/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octocat/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octocat/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octocat/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octocat/Hello-World/downloads", "events_url": "https://api.github.com/repos/octocat/Hello-World/events", "forks_url": "https://api.github.com/repos/octocat/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octocat/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octocat/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octocat/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octocat/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octocat/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octocat/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octocat/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octocat/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octocat/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octocat/Hello-World/languages", "merges_url": "https://api.github.com/repos/octocat/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octocat/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octocat/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octocat/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octocat/Hello-World/releases{/id}", "ssh_url": "git@github.com:octocat/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octocat/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octocat/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octocat/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octocat/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octocat/Hello-World/tags", "teams_url": "https://api.github.com/repos/octocat/Hello-World/teams", "trees_url": "https://api.github.com/repos/octocat/Hello-World/git/trees{/sha}", "clone_url": "https://github.com/octocat/Hello-World.git", "mirror_url": "git:git.example.com/octocat/Hello-World", "hooks_url": "https://api.github.com/repos/octocat/Hello-World/hooks", "svn_url": "https://svn.github.com/octocat/Hello-World", "homepage": "https://github.com", "language": null, "forks_count": 9, "stargazers_count": 80, "watchers_count": 80, "size": 108, "default_branch": "master", "open_issues_count": 0, "is_template": true, "topics": [ "octocat", "atom", "electron", "api" ], "has_issues": true, "has_projects": true, "has_wiki": true, "has_pages": false, "has_downloads": true, "archived": false, "disabled": false, "visibility": "public", "pushed_at": "2011-01-26T19:06:43Z", "created_at": "2011-01-26T19:01:12Z", "updated_at": "2011-01-26T19:14:43Z", "permissions": { "admin": false, "push": false, "pull": true }, "allow_rebase_merge": true, "template_repository": null, "temp_clone_token": "ABTLWHOULUVAXGTRYU7OC2876QJ2O", "allow_squash_merge": true, "allow_auto_merge": false, "delete_branch_on_merge": true, "allow_merge_commit": true, "subscribers_count": 42, "network_count": 0, "license": { "key": "mit", "name": "MIT License", "url": "https://api.github.com/licenses/mit", "spdx_id": "MIT", "node_id": "MDc6TGljZW5zZW1pdA==", "html_url": "https://github.com/licenses/mit" }, "forks": 1, "open_issues": 1, "watchers": 1 } ] }

Sets repositories for a required workflow

适用于 GitHub Apps

Sets the repositories for a required workflow that is required for selected repositories.

You must authenticate using an access token with the admin:org scope to use this endpoint.

For more information, see "Required Workflows."

“Sets repositories for a required workflow”的参数

标头
名称, 类型, 说明
acceptstring

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
orgstring必选

The organization name. The name is not case sensitive.

required_workflow_idinteger必选

The unique identifier of the required workflow.

正文参数
名称, 类型, 说明
selected_repository_idsarray of integers必选

The IDs of the repositories for which the workflow should be required.

“Sets repositories for a required workflow”的 HTTP 响应状态代码

状态代码说明
204

No Content

“Sets repositories for a required workflow”的示例代码

put/orgs/{org}/actions/required_workflows/{required_workflow_id}/repositories
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/actions/required_workflows/REQUIRED_WORKFLOW_ID/repositories \ -d '{"selected_repository_ids":[32,91]}'

Response

Status: 204

Add a repository to a required workflow

适用于 GitHub Apps

Adds a repository to a required workflow. To use this endpoint, the required workflow must be configured to run on selected repositories.

You must authenticate using an access token with the admin:org scope to use this endpoint.

For more information, see "Required Workflows."

“Add a repository to a required workflow”的参数

标头
名称, 类型, 说明
acceptstring

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
orgstring必选

The organization name. The name is not case sensitive.

required_workflow_idinteger必选

The unique identifier of the required workflow.

repository_idinteger必选

The unique identifier of the repository.

“Add a repository to a required workflow”的 HTTP 响应状态代码

状态代码说明
204

Success

404

Resource Not Found

422

Validation Error

“Add a repository to a required workflow”的示例代码

put/orgs/{org}/actions/required_workflows/{required_workflow_id}/repositories/{repository_id}
curl -L \ -X PUT \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/actions/required_workflows/REQUIRED_WORKFLOW_ID/repositories/REPOSITORY_ID

Success

Status: 204

Remove a selected repository from required workflow

适用于 GitHub Apps

Removes a repository from a required workflow. To use this endpoint, the required workflow must be configured to run on selected repositories.

You must authenticate using an access token with the admin:org scope to use this endpoint.

For more information, see "Required Workflows."

“Remove a selected repository from required workflow”的参数

标头
名称, 类型, 说明
acceptstring

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
orgstring必选

The organization name. The name is not case sensitive.

required_workflow_idinteger必选

The unique identifier of the required workflow.

repository_idinteger必选

The unique identifier of the repository.

“Remove a selected repository from required workflow”的 HTTP 响应状态代码

状态代码说明
204

Success

404

Resource Not Found

422

Validation Error

“Remove a selected repository from required workflow”的示例代码

delete/orgs/{org}/actions/required_workflows/{required_workflow_id}/repositories/{repository_id}
curl -L \ -X DELETE \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/orgs/ORG/actions/required_workflows/REQUIRED_WORKFLOW_ID/repositories/REPOSITORY_ID

Success

Status: 204

List repository required workflows

适用于 GitHub Apps

Lists the required workflows in a repository. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint. For more information, see "Required Workflows."

“List repository required workflows”的参数

标头
名称, 类型, 说明
acceptstring

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
orgstring必选

The organization name. The name is not case sensitive.

repostring必选

The name of the repository. The name is not case sensitive.

查询参数
名称, 类型, 说明
per_pageinteger

The number of results per page (max 100).

默认: 30

pageinteger

Page number of the results to fetch.

默认: 1

“List repository required workflows”的 HTTP 响应状态代码

状态代码说明
200

OK

404

Resource not found

“List repository required workflows”的示例代码

get/repos/{org}/{repo}/actions/required_workflows
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/ORG/REPO/actions/required_workflows

Response

Status: 200
{ "total_count": 1, "required_workflows": [ { "id": 161335, "node_id": "MDg6V29ya2Zsb3cxNjEzMzU=", "name": "RequiredCI", "path": ".github/workflows/required_ci.yaml", "state": "active", "created_at": "2020-01-08T23:48:37.000-08:00", "updated_at": "2020-01-08T23:50:21.000-08:00", "url": "https://api.github.com/repos/octo-org/octo-repo/actions/required_workflows/161335", "html_url": "https://github.com/octo-org/octo-repo/blob/master/octo-org/hello-world/.github/workflows/required_ci.yaml", "badge_url": "https://github.com/octo-org/octo-repo/workflows/required/octo-org/hello-world/.github/workflows/required_ci.yaml/badge.svg", "source_repository": { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octo-org/Hello-World", "owner": { "login": "octo-org", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octo-org_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octo-org", "html_url": "https://github.com/octo-org", "followers_url": "https://api.github.com/users/octo-org/followers", "following_url": "https://api.github.com/users/octo-org/following{/other_user}", "gists_url": "https://api.github.com/users/octo-org/gists{/gist_id}", "starred_url": "https://api.github.com/users/octo-org/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octo-org/subscriptions", "organizations_url": "https://api.github.com/users/octo-org/orgs", "repos_url": "https://api.github.com/users/octo-org/repos", "events_url": "https://api.github.com/users/octo-org/events{/privacy}", "received_events_url": "https://api.github.com/users/octo-org/received_events", "type": "User", "site_admin": false }, "private": false, "html_url": "https://github.com/octo-org/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octo-org/Hello-World", "archive_url": "https://api.github.com/repos/octo-org/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octo-org/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octo-org/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octo-org/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octo-org/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octo-org/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octo-org/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octo-org/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octo-org/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octo-org/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octo-org/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octo-org/Hello-World/downloads", "events_url": "https://api.github.com/repos/octo-org/Hello-World/events", "forks_url": "https://api.github.com/repos/octo-org/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octo-org/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octo-org/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octo-org/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octo-org/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octo-org/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octo-org/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octo-org/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octo-org/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octo-org/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octo-org/Hello-World/languages", "merges_url": "https://api.github.com/repos/octo-org/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octo-org/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octo-org/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octo-org/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octo-org/Hello-World/releases{/id}", "ssh_url": "git@github.com:octo-org/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octo-org/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octo-org/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octo-org/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octo-org/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octo-org/Hello-World/tags", "teams_url": "https://api.github.com/repos/octo-org/Hello-World/teams", "trees_url": "https://api.github.com/repos/octo-org/Hello-World/git/trees{/sha}", "hooks_url": "http://api.github.com/repos/octo-org/Hello-World/hooks" } } ] }

Get a required workflow entity for a repository

适用于 GitHub Apps

Gets a specific required workflow present in a repository. Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint. For more information, see "Required Workflows."

“Get a required workflow entity for a repository”的参数

标头
名称, 类型, 说明
acceptstring

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
orgstring必选

The organization name. The name is not case sensitive.

repostring必选

The name of the repository. The name is not case sensitive.

required_workflow_id_for_repointeger必选

The ID of the required workflow that has run at least once in a repository.

“Get a required workflow entity for a repository”的 HTTP 响应状态代码

状态代码说明
200

OK

404

Resource not found

“Get a required workflow entity for a repository”的示例代码

get/repos/{org}/{repo}/actions/required_workflows/{required_workflow_id_for_repo}
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/ORG/REPO/actions/required_workflows/REQUIRED_WORKFLOW_ID_FOR_REPO

Response

Status: 200
{ "id": 161335, "node_id": "MDg6V29ya2Zsb3cxNjEzMzU=", "name": "RequiredCI", "path": ".github/workflows/required_ci.yaml", "state": "active", "created_at": "2020-01-08T23:48:37.000-08:00", "updated_at": "2020-01-08T23:50:21.000-08:00", "url": "https://api.github.com/repos/octo-org/octo-repo/actions/required_workflows/161335", "html_url": "https://github.com/octo-org/octo-repo/blob/master/octo-org/hello-world/.github/workflows/required_ci.yaml", "badge_url": "https://github.com/octo-org/octo-repo/workflows/required/octo-org/hello-world/.github/workflows/required_ci.yaml/badge.svg", "source_repository": { "id": 1296269, "node_id": "MDEwOlJlcG9zaXRvcnkxMjk2MjY5", "name": "Hello-World", "full_name": "octo-org/Hello-World", "owner": { "login": "octo-org", "id": 1, "node_id": "MDQ6VXNlcjE=", "avatar_url": "https://github.com/images/error/octo-org_happy.gif", "gravatar_id": "", "url": "https://api.github.com/users/octo-org", "html_url": "https://github.com/octo-org", "followers_url": "https://api.github.com/users/octo-org/followers", "following_url": "https://api.github.com/users/octo-org/following{/other_user}", "gists_url": "https://api.github.com/users/octo-org/gists{/gist_id}", "starred_url": "https://api.github.com/users/octo-org/starred{/owner}{/repo}", "subscriptions_url": "https://api.github.com/users/octo-org/subscriptions", "organizations_url": "https://api.github.com/users/octo-org/orgs", "repos_url": "https://api.github.com/users/octo-org/repos", "events_url": "https://api.github.com/users/octo-org/events{/privacy}", "received_events_url": "https://api.github.com/users/octo-org/received_events", "type": "User", "site_admin": false }, "private": false, "html_url": "https://github.com/octo-org/Hello-World", "description": "This your first repo!", "fork": false, "url": "https://api.github.com/repos/octo-org/Hello-World", "archive_url": "https://api.github.com/repos/octo-org/Hello-World/{archive_format}{/ref}", "assignees_url": "https://api.github.com/repos/octo-org/Hello-World/assignees{/user}", "blobs_url": "https://api.github.com/repos/octo-org/Hello-World/git/blobs{/sha}", "branches_url": "https://api.github.com/repos/octo-org/Hello-World/branches{/branch}", "collaborators_url": "https://api.github.com/repos/octo-org/Hello-World/collaborators{/collaborator}", "comments_url": "https://api.github.com/repos/octo-org/Hello-World/comments{/number}", "commits_url": "https://api.github.com/repos/octo-org/Hello-World/commits{/sha}", "compare_url": "https://api.github.com/repos/octo-org/Hello-World/compare/{base}...{head}", "contents_url": "https://api.github.com/repos/octo-org/Hello-World/contents/{+path}", "contributors_url": "https://api.github.com/repos/octo-org/Hello-World/contributors", "deployments_url": "https://api.github.com/repos/octo-org/Hello-World/deployments", "downloads_url": "https://api.github.com/repos/octo-org/Hello-World/downloads", "events_url": "https://api.github.com/repos/octo-org/Hello-World/events", "forks_url": "https://api.github.com/repos/octo-org/Hello-World/forks", "git_commits_url": "https://api.github.com/repos/octo-org/Hello-World/git/commits{/sha}", "git_refs_url": "https://api.github.com/repos/octo-org/Hello-World/git/refs{/sha}", "git_tags_url": "https://api.github.com/repos/octo-org/Hello-World/git/tags{/sha}", "git_url": "git:github.com/octo-org/Hello-World.git", "issue_comment_url": "https://api.github.com/repos/octo-org/Hello-World/issues/comments{/number}", "issue_events_url": "https://api.github.com/repos/octo-org/Hello-World/issues/events{/number}", "issues_url": "https://api.github.com/repos/octo-org/Hello-World/issues{/number}", "keys_url": "https://api.github.com/repos/octo-org/Hello-World/keys{/key_id}", "labels_url": "https://api.github.com/repos/octo-org/Hello-World/labels{/name}", "languages_url": "https://api.github.com/repos/octo-org/Hello-World/languages", "merges_url": "https://api.github.com/repos/octo-org/Hello-World/merges", "milestones_url": "https://api.github.com/repos/octo-org/Hello-World/milestones{/number}", "notifications_url": "https://api.github.com/repos/octo-org/Hello-World/notifications{?since,all,participating}", "pulls_url": "https://api.github.com/repos/octo-org/Hello-World/pulls{/number}", "releases_url": "https://api.github.com/repos/octo-org/Hello-World/releases{/id}", "ssh_url": "git@github.com:octo-org/Hello-World.git", "stargazers_url": "https://api.github.com/repos/octo-org/Hello-World/stargazers", "statuses_url": "https://api.github.com/repos/octo-org/Hello-World/statuses/{sha}", "subscribers_url": "https://api.github.com/repos/octo-org/Hello-World/subscribers", "subscription_url": "https://api.github.com/repos/octo-org/Hello-World/subscription", "tags_url": "https://api.github.com/repos/octo-org/Hello-World/tags", "teams_url": "https://api.github.com/repos/octo-org/Hello-World/teams", "trees_url": "https://api.github.com/repos/octo-org/Hello-World/git/trees{/sha}", "hooks_url": "http://api.github.com/repos/octo-org/Hello-World/hooks" } }

Get required workflow usage

Gets the number of billable minutes used by a specific required workflow during the current billing cycle.

Billable minutes only apply to required workflows running in private repositories that use GitHub Enterprise Cloud-hosted runners. Usage is listed for each GitHub Enterprise Cloud-hosted runner operating system in milliseconds. Any job re-runs are also included in the usage. The usage does not include the multiplier for macOS and Windows runners and is not rounded up to the nearest whole minute. For more information, see "Managing billing for GitHub Actions."

Anyone with read access to the repository can use this endpoint. If the repository is private you must use an access token with the repo scope. GitHub Apps must have the actions:read permission to use this endpoint.

“Get required workflow usage”的参数

标头
名称, 类型, 说明
acceptstring

Setting to application/vnd.github+json is recommended.

路径参数
名称, 类型, 说明
orgstring必选

The organization name. The name is not case sensitive.

repostring必选

The name of the repository. The name is not case sensitive.

required_workflow_id_for_repointeger必选

The ID of the required workflow that has run at least once in a repository.

“Get required workflow usage”的 HTTP 响应状态代码

状态代码说明
200

OK

404

Resource not found

“Get required workflow usage”的示例代码

get/repos/{org}/{repo}/actions/required_workflows/{required_workflow_id_for_repo}/timing
curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>"\ -H "X-GitHub-Api-Version: 2022-11-28" \ https://api.github.com/repos/ORG/REPO/actions/required_workflows/REQUIRED_WORKFLOW_ID_FOR_REPO/timing

Response

Status: 200
{ "billable": { "UBUNTU": { "total_ms": 180000 }, "MACOS": { "total_ms": 240000 }, "WINDOWS": { "total_ms": 300000 } } }