跳至主要内容
REST API 现在已版本化。 有关更多信息,请参阅“关于 API 版本控制”。

GitHub Pages 的 REST API 端点

使用 REST API 与 GitHub Pages 站点和构建进行交互。

获取 GitHub Pages 站点

获取有关 GitHub Pages 站点的信息。

OAuth 应用程序令牌和个人访问令牌(经典)需要 repo 范围才能使用此端点。

“获取 GitHub Pages 站点”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌必须具有以下权限集

  • “Pages” 存储库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

“获取 GitHub Pages 站点”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称,类型,描述
owner 字符串 必填

存储库的帐户所有者。名称不区分大小写。

repo 字符串 必填

存储库的名称,不带 .git 扩展名。名称不区分大小写。

“获取 GitHub Pages 站点”的 HTTP 响应状态代码

状态代码描述
200

OK

404

资源未找到

“获取 GitHub Pages 站点”的代码示例

请求示例

get/repos/{owner}/{repo}/pages
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/OWNER/REPO/pages

响应

状态:200
{ "url": "https://api.github.com/repos/github/developer.github.com/pages", "status": "built", "cname": "developer.github.com", "custom_404": false, "html_url": "https://developer.github.com", "source": { "branch": "master", "path": "/" }, "public": true, "pending_domain_unverified_at": "2024-04-30T19:33:31Z", "protected_domain_state": "verified", "https_certificate": { "state": "approved", "description": "Certificate is approved", "domains": [ "developer.github.com" ], "expires_at": "2021-05-22" }, "https_enforced": true }

创建 GitHub Pages 站点

配置 GitHub Pages 站点。有关更多信息,请参阅“关于 GitHub Pages”。

经过身份验证的用户必须是存储库管理员、维护者或具有“管理 GitHub Pages 设置”权限。

OAuth 应用程序令牌和个人访问令牌(经典)需要 repo 范围才能使用此端点。

“创建 GitHub Pages 站点”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌必须具有以下权限集

  • “Pages” 存储库权限(写入)“管理” 存储库权限(写入)

“创建 GitHub Pages 站点”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称,类型,描述
owner 字符串 必填

存储库的帐户所有者。名称不区分大小写。

repo 字符串 必填

存储库的名称,不带 .git 扩展名。名称不区分大小写。

主体参数
名称,类型,描述
build_type 字符串

页面将构建的过程。可能的值为 "legacy""workflow"

可以是以下之一: legacy, workflow

source 对象

用于发布 Pages 站点的源分支和目录。

名称,类型,描述
branch 字符串 必填

用于发布站点源文件的存储库分支。

path 字符串

包含 Pages 站点源文件的存储库目录。允许的路径为 //docs。默认值:/

默认值: /

可以是以下之一: /, /docs

“创建 GitHub Pages 站点”的 HTTP 响应状态代码

状态代码描述
201

已创建

409

冲突

422

验证失败,或端点已被垃圾邮件轰炸。

“创建 GitHub Pages 站点”的代码示例

请求示例

post/repos/{owner}/{repo}/pages
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/repos/OWNER/REPO/pages \ -d '{"source":{"branch":"main","path":"/docs"}}'

响应

状态:201
{ "url": "https://api.github.com/repos/github/developer.github.com/pages", "status": "built", "cname": "developer.github.com", "custom_404": false, "html_url": "https://developer.github.com", "source": { "branch": "master", "path": "/" }, "public": true, "pending_domain_unverified_at": "2024-04-30T19:33:31Z", "protected_domain_state": "verified", "https_certificate": { "state": "approved", "description": "Certificate is approved", "domains": [ "developer.github.com" ], "expires_at": "2021-05-22" }, "https_enforced": true }

更新 GitHub Pages 站点信息

更新 GitHub Pages 站点的信息。有关更多信息,请参阅“关于 GitHub Pages

经过身份验证的用户必须是存储库管理员、维护者或具有“管理 GitHub Pages 设置”权限。

OAuth 应用程序令牌和个人访问令牌(经典)需要 repo 范围才能使用此端点。

“更新 GitHub Pages 站点信息”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌必须具有以下权限集

  • “Pages” 存储库权限(写入)“管理” 存储库权限(写入)

“更新 GitHub Pages 站点信息”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称,类型,描述
owner 字符串 必填

存储库的帐户所有者。名称不区分大小写。

repo 字符串 必填

存储库的名称,不带 .git 扩展名。名称不区分大小写。

主体参数
名称,类型,描述
cname 字符串或 null

为存储库指定自定义域名。发送 null 值将删除自定义域名。有关自定义域的更多信息,请参阅“使用 GitHub Pages 的自定义域名”。

https_enforced 布尔值

指定是否应为存储库强制执行 HTTPS。

build_type 字符串

GitHub Pages 站点将构建的过程。workflow 表示站点由自定义 GitHub Actions 工作流构建。legacy 表示当更改推送到特定分支时,站点由 GitHub 构建。

可以是以下之一: legacy, workflow

source 对象

更新存储库的源。必须包含分支名称和路径。

名称,类型,描述
branch 字符串 必填

用于发布站点源文件的存储库分支。

path 字符串 必填

包含 Pages 站点源文件的存储库目录。允许的路径为 //docs

可以是以下之一: /, /docs

“更新 GitHub Pages 站点信息”的 HTTP 响应状态代码

状态代码描述
204

无内容

400

错误请求

409

冲突

422

验证失败,或端点已被垃圾邮件轰炸。

“更新 GitHub Pages 站点信息”的代码示例

请求示例

put/repos/{owner}/{repo}/pages
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/repos/OWNER/REPO/pages \ -d '{"cname":"octocatblog.com","source":{"branch":"main","path":"/"}}'

响应

状态:204

删除 GitHub Pages 站点

删除 GitHub Pages 站点。有关更多信息,请参阅“关于 GitHub Pages

经过身份验证的用户必须是存储库管理员、维护者或具有“管理 GitHub Pages 设置”权限。

OAuth 应用程序令牌和个人访问令牌(经典)需要 repo 范围才能使用此端点。

“删除 GitHub Pages 站点”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌必须具有以下权限集

  • “Pages” 存储库权限(写入)“管理” 存储库权限(写入)

“删除 GitHub Pages 站点”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称,类型,描述
owner 字符串 必填

存储库的帐户所有者。名称不区分大小写。

repo 字符串 必填

存储库的名称,不带 .git 扩展名。名称不区分大小写。

“删除 GitHub Pages 站点”的 HTTP 响应状态代码

状态代码描述
204

无内容

404

资源未找到

409

冲突

422

验证失败,或端点已被垃圾邮件轰炸。

“删除 GitHub Pages 站点”的代码示例

请求示例

delete/repos/{owner}/{repo}/pages
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/repos/OWNER/REPO/pages

响应

状态:204

列出 GitHub Pages 构建

列出 GitHub Pages 站点的构建。

OAuth 应用程序令牌和个人访问令牌(经典)需要 repo 范围才能使用此端点。

“列出 GitHub Pages 构建”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌必须具有以下权限集

  • “Pages” 存储库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

“列出 GitHub Pages 构建”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称,类型,描述
owner 字符串 必填

存储库的帐户所有者。名称不区分大小写。

repo 字符串 必填

存储库的名称,不带 .git 扩展名。名称不区分大小写。

查询参数
名称,类型,描述
per_page 整数

每页的结果数(最大 100)。有关更多信息,请参阅“在 REST API 中使用分页”。

默认值: 30

page 整数

要获取的结果的页码。有关更多信息,请参阅“在 REST API 中使用分页”。

默认值: 1

“列出 GitHub Pages 构建”的 HTTP 响应状态代码

状态代码描述
200

OK

“列出 GitHub Pages 构建”的代码示例

请求示例

获取/repos/{owner}/{repo}/pages/builds
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/OWNER/REPO/pages/builds

响应

状态:200
[ { "url": "https://api.github.com/repos/github/developer.github.com/pages/builds/5472601", "status": "built", "error": { "message": null }, "pusher": { "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 }, "commit": "351391cdcb88ffae71ec3028c91f375a8036a26b", "duration": 2104, "created_at": "2014-02-10T19:00:49Z", "updated_at": "2014-02-10T19:00:51Z" } ]

请求 GitHub Pages 构建

您可以请求从默认分支的最新版本构建您的站点。这与将提交推送到您的默认分支具有相同的效果,但不需要额外的提交。在诊断构建警告和错误时,手动触发页面构建可能会有所帮助。

构建请求限于每个仓库一个并发构建和每个请求者一个并发构建。如果您在另一个构建仍在进行时请求构建,则第二个请求将排队,直到第一个构建完成。

“请求 GitHub Pages 构建”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌必须具有以下权限集

  • “Pages” 仓库权限(写入)

“请求 GitHub Pages 构建”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称,类型,描述
owner 字符串 必填

存储库的帐户所有者。名称不区分大小写。

repo 字符串 必填

存储库的名称,不带 .git 扩展名。名称不区分大小写。

“请求 GitHub Pages 构建”的 HTTP 响应状态代码

状态代码描述
201

已创建

“请求 GitHub Pages 构建”的代码示例

请求示例

发布/repos/{owner}/{repo}/pages/builds
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/repos/OWNER/REPO/pages/builds

响应

状态:201
{ "url": "https://api.github.com/repos/github/developer.github.com/pages/builds/latest", "status": "queued" }

获取最新的 Pages 构建

获取有关 GitHub Pages 站点最近一次构建的信息。

OAuth 应用程序令牌和个人访问令牌(经典)需要 repo 范围才能使用此端点。

“获取最新的 Pages 构建”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌必须具有以下权限集

  • “Pages” 存储库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

“获取最新的 Pages 构建”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称,类型,描述
owner 字符串 必填

存储库的帐户所有者。名称不区分大小写。

repo 字符串 必填

存储库的名称,不带 .git 扩展名。名称不区分大小写。

“获取最新的 Pages 构建”的 HTTP 响应状态代码

状态代码描述
200

OK

“获取最新的 Pages 构建”的代码示例

请求示例

获取/repos/{owner}/{repo}/pages/builds/latest
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/OWNER/REPO/pages/builds/latest

响应

状态:200
{ "url": "https://api.github.com/repos/github/developer.github.com/pages/builds/5472601", "status": "built", "error": { "message": null }, "pusher": { "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 }, "commit": "351391cdcb88ffae71ec3028c91f375a8036a26b", "duration": 2104, "created_at": "2014-02-10T19:00:49Z", "updated_at": "2014-02-10T19:00:51Z" }

获取 GitHub Pages 构建

获取有关 GitHub Pages 构建的信息。

OAuth 应用程序令牌和个人访问令牌(经典)需要 repo 范围才能使用此端点。

“获取 GitHub Pages 构建”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌必须具有以下权限集

  • “Pages” 存储库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

“获取 GitHub Pages 构建”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称,类型,描述
owner 字符串 必填

存储库的帐户所有者。名称不区分大小写。

repo 字符串 必填

存储库的名称,不带 .git 扩展名。名称不区分大小写。

build_id 整数 必需

“获取 GitHub Pages 构建”的 HTTP 响应状态代码

状态代码描述
200

OK

“获取 GitHub Pages 构建”的代码示例

请求示例

获取/repos/{owner}/{repo}/pages/builds/{build_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/repos/OWNER/REPO/pages/builds/BUILD_ID

响应

状态:200
{ "url": "https://api.github.com/repos/github/developer.github.com/pages/builds/5472601", "status": "built", "error": { "message": null }, "pusher": { "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 }, "commit": "351391cdcb88ffae71ec3028c91f375a8036a26b", "duration": 2104, "created_at": "2014-02-10T19:00:49Z", "updated_at": "2014-02-10T19:00:51Z" }

创建 GitHub Pages 部署

为仓库创建 GitHub Pages 部署。

经过身份验证的用户必须对仓库具有写入权限。

“创建 GitHub Pages 部署”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌必须具有以下权限集

  • “Pages” 仓库权限(写入)

“创建 GitHub Pages 部署”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称,类型,描述
owner 字符串 必填

存储库的帐户所有者。名称不区分大小写。

repo 字符串 必填

存储库的名称,不带 .git 扩展名。名称不区分大小写。

主体参数
名称,类型,描述
artifact_id 数字

包含要部署的静态资产的 .zip 或 .tar 的工件的 ID。该工件属于仓库。artifact_idartifact_url 是必需的。

artifact_url 字符串

包含要部署的静态资产的 .zip 或 .tar 的工件的 URL。该工件属于仓库。artifact_idartifact_url 是必需的。

environment 字符串

此 GitHub Pages 部署的目标环境。

默认: github-pages

pages_build_version 字符串 必需

表示此部署构建版本的唯一字符串。

默认: GITHUB_SHA

oidc_token 字符串 必需

由 GitHub Actions 发出的 OIDC 令牌,用于证明部署的来源。

“创建 GitHub Pages 部署”的 HTTP 响应状态代码

状态代码描述
200

OK

400

错误请求

404

资源未找到

422

验证失败,或端点已被垃圾邮件轰炸。

“创建 GitHub Pages 部署”的代码示例

请求示例

发布/repos/{owner}/{repo}/pages/deployments
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/repos/OWNER/REPO/pages/deployments \ -d '{"artifact_url":"https://downloadcontent/","environment":"github-pages","pages_build_version":"4fd754f7e594640989b406850d0bc8f06a121251","oidc_token":"eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IlV2R1h4SUhlY0JFc1JCdEttemUxUEhfUERiVSIsImtpZCI6IjUyRjE5N0M0ODFERTcwMTEyQzQ0MUI0QTlCMzdCNTNDN0ZDRjBEQjUifQ.eyJqdGkiOiJhMWIwNGNjNy0zNzZiLTQ1N2QtOTMzNS05NTY5YmVjZDExYTIiLCJzdWIiOiJyZXBvOnBhcGVyLXNwYS9taW55aTplbnZpcm9ubWVudDpQcm9kdWN0aW9uIiwiYXVkIjoiaHR0cHM6Ly9naXRodWIuY29tL3BhcGVyLXNwYSIsInJlZiI6InJlZnMvaGVhZHMvbWFpbiIsInNoYSI6ImEyODU1MWJmODdiZDk3NTFiMzdiMmM0YjM3M2MxZjU3NjFmYWM2MjYiLCJyZXBvc2l0b3J5IjoicGFwZXItc3BhL21pbnlpIiwicmVwb3NpdG9yeV9vd25lciI6InBhcGVyLXNwYSIsInJ1bl9pZCI6IjE1NDY0NTkzNjQiLCJydW5fbnVtYmVyIjoiMzQiLCJydW5fYXR0ZW1wdCI6IjYiLCJhY3RvciI6IllpTXlzdHkiLCJ3b3JrZmxvdyI6IkNJIiwiaGVhZF9yZWYiOiIiLCJiYXNlX3JlZiI6IiIsImV2ZW50X25hbWUiOiJwdXNoIiwicmVmX3R5cGUiOiJicmFuY2giLCJlbnZpcm9ubWVudCI6IlByb2R1Y3Rpb24iLCJqb2Jfd29ya2Zsb3dfcmVmIjoicGFwZXItc3BhL21pbnlpLy5naXRodWIvd29ya2Zsb3dzL2JsYW5rLnltbEByZWZzL2hlYWRzL21haW4iLCJpc3MiOiJodHRwczovL3Rva2VuLmFjdGlvbnMuZ2l0aHVidXNlcmNvbnRlbnQuY29tIiwibmJmIjoxNjM5MDAwODU2LCJleHAiOjE2MzkwMDE3NTYsImlhdCI6MTYzOTAwMTQ1Nn0.VP8WictbQECKozE2SgvKb2FqJ9hisWsoMkYRTqfBrQfZTCXi5IcFEdgDMB2X7a99C2DeUuTvHh9RMKXLL2a0zg3-Sd7YrO7a2ll2kNlnvyIypcN6AeIc7BxHsTTnZN9Ud_xmEsTrSRGOEKmzCFkULQ6N4zlVD0sidypmXlMemmWEcv_ZHqhioEI_VMp5vwXQurketWH7qX4oDgG4okyYtPrv5RQHbfQcVo9izaPJ_jnsDd0CBA0QOx9InjPidtIkMYQLyUgJy33HLJy86EFNUnAf8UhBQuQi5mAsEpEzBBuKpG3PDiPtYCHOk64JZkZGd5mR888a5sbHRiaF8hm8YA","preview":false}'

响应

状态:200
{ "id": "4fd754f7e594640989b406850d0bc8f06a121251", "status_url": "https://api.github.com/repos/github/developer.github.com/pages/deployments/4fd754f7e594640989b406850d0bc8f06a121251/status", "page_url": "developer.github.com" }

获取 GitHub Pages 部署的状态

获取 GitHub Pages 部署的当前状态。

经过身份验证的用户必须对 GitHub Pages 站点具有读取权限。

“获取 GitHub Pages 部署的状态”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌必须具有以下权限集

  • “Pages” 存储库权限(读取)

如果仅请求公共资源,则无需身份验证或上述权限即可使用此端点。

“获取 GitHub Pages 部署的状态”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称,类型,描述
owner 字符串 必填

存储库的帐户所有者。名称不区分大小写。

repo 字符串 必填

存储库的名称,不带 .git 扩展名。名称不区分大小写。

pages_deployment_id 必需

Pages 部署的 ID。您也可以提供部署的提交 SHA。

“获取 GitHub Pages 部署的状态”的 HTTP 响应状态代码

状态代码描述
200

OK

404

资源未找到

“获取 GitHub Pages 部署的状态”的代码示例

请求示例

获取/repos/{owner}/{repo}/pages/deployments/{pages_deployment_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/repos/OWNER/REPO/pages/deployments/PAGES_DEPLOYMENT_ID

响应

状态:200
{ "status": "succeed" }

取消 GitHub Pages 部署

取消 GitHub Pages 部署。

经过身份验证的用户必须对 GitHub Pages 站点具有写入权限。

“取消 GitHub Pages 部署”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌必须具有以下权限集

  • “Pages” 仓库权限(写入)

“取消 GitHub Pages 部署”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称,类型,描述
owner 字符串 必填

存储库的帐户所有者。名称不区分大小写。

repo 字符串 必填

存储库的名称,不带 .git 扩展名。名称不区分大小写。

pages_deployment_id 必需

Pages 部署的 ID。您也可以提供部署的提交 SHA。

“取消 GitHub Pages 部署”的 HTTP 响应状态代码

状态代码描述
204

返回一个没有内容的标头。

404

资源未找到

“取消 GitHub Pages 部署”的代码示例

请求示例

发布/repos/{owner}/{repo}/pages/deployments/{pages_deployment_id}/cancel
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/repos/OWNER/REPO/pages/deployments/PAGES_DEPLOYMENT_ID/cancel

返回一个没有内容的标头。

状态:204

获取 GitHub Pages 的 DNS 健康检查

获取为仓库的 GitHub Pages 配置的 CNAME 记录的 DNS 设置的健康检查。

对该端点的第一个请求返回 202 Accepted 状态并启动一个异步后台任务以获取域的结果。后台任务完成后,对该端点的后续请求将返回 200 OK 状态,并在响应中包含健康检查结果。

经过身份验证的用户必须是仓库管理员、维护者或具有“管理 GitHub Pages 设置”权限才能使用此端点。

OAuth 应用程序令牌和个人访问令牌(经典)需要 repo 范围才能使用此端点。

“获取 GitHub Pages 的 DNS 健康检查”的细粒度访问令牌

此端点适用于以下细粒度令牌类型:

细粒度令牌必须具有以下权限集

  • “管理”仓库权限(写入)“Pages” 仓库权限(写入)

“获取 GitHub Pages 的 DNS 健康检查”的参数

标头
名称,类型,描述
accept 字符串

建议设置为 application/vnd.github+json

路径参数
名称,类型,描述
owner 字符串 必填

存储库的帐户所有者。名称不区分大小写。

repo 字符串 必填

存储库的名称,不带 .git 扩展名。名称不区分大小写。

“获取 GitHub Pages 的 DNS 健康检查”的 HTTP 响应状态代码

状态代码描述
200

OK

202

空响应

400

GitHub Pages 不提供自定义域名

404

资源未找到

422

此页面没有 CNAME

“获取 GitHub Pages 的 DNS 健康检查” 代码示例

请求示例

获取/repos/{owner}/{repo}/pages/health
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/OWNER/REPO/pages/health

响应

状态:200
{ "domain": { "host": "example.com", "uri": "http://example.com/", "nameservers": "default", "dns_resolves": true, "is_proxied": false, "is_cloudflare_ip": false, "is_fastly_ip": false, "is_old_ip_address": false, "is_a_record": true, "has_cname_record": false, "has_mx_records_present": false, "is_valid_domain": true, "is_apex_domain": true, "should_be_a_record": true, "is_cname_to_github_user_domain": false, "is_cname_to_pages_dot_github_dot_com": false, "is_cname_to_fastly": false, "is_pointed_to_github_pages_ip": true, "is_non_github_pages_ip_present": false, "is_pages_domain": false, "is_served_by_pages": true, "is_valid": true, "reason": null, "responds_to_https": true, "enforces_https": true, "https_error": null, "is_https_eligible": true, "caa_error": null }, "alt_domain": { "host": "www.example.com", "uri": "http://www.example.com/", "nameservers": "default", "dns_resolves": true, "is_proxied": false, "is_cloudflare_ip": false, "is_fastly_ip": false, "is_old_ip_address": false, "is_a_record": true, "has_cname_record": false, "has_mx_records_present": false, "is_valid_domain": true, "is_apex_domain": true, "should_be_a_record": true, "is_cname_to_github_user_domain": false, "is_cname_to_pages_dot_github_dot_com": false, "is_cname_to_fastly": false, "is_pointed_to_github_pages_ip": true, "is_non_github_pages_ip_present": false, "is_pages_domain": false, "is_served_by_pages": true, "is_valid": true, "reason": null, "responds_to_https": true, "enforces_https": true, "https_error": null, "is_https_eligible": true, "caa_error": null } }