GitHub Pages API は、GitHub Pages の設定や、ビルドのステータスについての情� �を取得します。 サイトとビルドに関する情� �は、Webサイトがパブリックの� �合であっても認証を受けたユーザ� けがアクセスできます。 詳しい情� �については、「GitHub Pages について」を参照してく� さい。
レスポンスに status
キーを持つ GitHub Pages API エンドポイントにおいては、値は以下のいずれかになります。
null
: サイトはま� ビルドされていません。queued
: ビルドがリクエストされたが、ま� 開始していません。building
: ビルドが進行中です。built
: サイトがビルドされています。errored
: ビルド中にエラーが発生したことを示します。
GitHub Pages サイトの情� �を返す GitHub Pages API エンドポイントにおいては、JSON のレスポンスには以下が含まれます。
html_url
: レンダリングされた Pages サイトの絶対 URL (スキー� を含む) 。 たとえば、https://username.github.io
などです。source
: レンダリングされた Pages サイトのソースブランチおよびディレクトリを含むオブジェクト。 これは以下のものが含まれます。branch
: サイトのソースファイルを公開するために使用するリポジトリのブランチ。 たとえば、main or gh-pages などです。path
: サイトの公開元のリポジトリディレクトリ。/
または/docs
のどちらかとなります。
get /repos/{owner}/{repo}/pages
パラメータ
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path |
コードサンプル
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/pages
JavaScript (@octokit/core.js)
await octokit.request('GET /repos/{owner}/{repo}/pages', {
owner: 'octocat',
repo: 'hello-world'
})
Response
Status: 200 OK
{
"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,
"https_certificate": {
"state": "approved",
"description": "Certificate is approved",
"domains": [
"developer.github.com"
],
"expires_at": "2021-05-22"
},
"https_enforced": true
}
Resource not found
Status: 404 Not Found
Notes
Create a GitHub Enterprise Server Pages site
Configures a GitHub Enterprise Server Pages site. For more information, see "About GitHub Pages."
post /repos/{owner}/{repo}/pages
パラメータ
Name | Type | In | Description | ||||||
---|---|---|---|---|---|---|---|---|---|
accept |
string | header |
Setting to
|
||||||
owner |
string | path | |||||||
repo |
string | path | |||||||
source |
object | body |
Required. The source branch and directory used to publish your Pages site. |
||||||
Properties of the
|
Name (Type) | Description |
---|---|
branch (string)
|
Required. The repository branch used to publish your site's source files. |
path (string)
|
The repository directory that includes the source files for the Pages site. Allowed paths are |
コードサンプル
Shell
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/pages \
-d '{"source":{"branch":"branch","path":"path"}}'
JavaScript (@octokit/core.js)
await octokit.request('POST /repos/{owner}/{repo}/pages', {
owner: 'octocat',
repo: 'hello-world',
source: {
branch: 'branch',
path: 'path'
}
})
Response
Status: 201 Created
{
"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,
"https_certificate": {
"state": "approved",
"description": "Certificate is approved",
"domains": [
"developer.github.com"
],
"expires_at": "2021-05-22"
},
"https_enforced": true
}
Conflict
Status: 409 Conflict
Validation failed
Status: 422 Unprocessable Entity
Notes
プレビュー通知
Enabling and disabling Pages in the Pages API is currently available for developers to preview. See the blog post preview for more details. To access the new endpoints during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.switcheroo-preview+json
Update information about a GitHub Enterprise Server Pages site
Updates information for a GitHub Enterprise Server Pages site. For more information, see "About GitHub Pages.
put /repos/{owner}/{repo}/pages
パラメータ
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path | |
cname |
string or nullable | body |
Specify a custom domain for the repository. Sending a |
https_enforced |
boolean | body |
Specify whether HTTPS should be enforced for the repository. |
public |
boolean | body |
Configures access controls for the GitHub Pages site. If public is set to |
source |
body |
コードサンプル
Shell
curl \
-X PUT \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/pages \
-d '{"cname":"cname"}'
JavaScript (@octokit/core.js)
await octokit.request('PUT /repos/{owner}/{repo}/pages', {
owner: 'octocat',
repo: 'hello-world',
cname: 'cname'
})
Response
Status: 204 No Content
Bad Request
Status: 400 Bad Request
Validation failed
Status: 422 Unprocessable Entity
Notes
delete /repos/{owner}/{repo}/pages
パラメータ
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path |
コードサンプル
Shell
curl \
-X DELETE \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/pages
JavaScript (@octokit/core.js)
await octokit.request('DELETE /repos/{owner}/{repo}/pages', {
owner: 'octocat',
repo: 'hello-world'
})
Response
Status: 204 No Content
Resource not found
Status: 404 Not Found
Validation failed
Status: 422 Unprocessable Entity
Notes
プレビュー通知
Enabling and disabling Pages in the Pages API is currently available for developers to preview. See the blog post preview for more details. To access the new endpoints during the preview period, you must provide a custom media type in the Accept
header:
application/vnd.github.switcheroo-preview+json
get /repos/{owner}/{repo}/pages/builds
パラメータ
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path | |
per_page |
integer | query |
Results per page (max 100) Default:30 |
page |
integer | query |
Page number of the results to fetch. Default:1 |
コードサンプル
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/pages/builds
JavaScript (@octokit/core.js)
await octokit.request('GET /repos/{owner}/{repo}/pages/builds', {
owner: 'octocat',
repo: 'hello-world'
})
Response
Status: 200 OK
[
{
"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"
}
]
Notes
Request a GitHub Enterprise Server Pages build
You can request that your site be built from the latest revision on the default branch. This has the same effect as pushing a commit to your default branch, but does not require an additional commit. Manually triggering page builds can be helpful when diagnosing build warnings and failures.
Build requests are limited to one concurrent build per repository and one concurrent build per requester. If you request a build while another is still in progress, the second request will be queued until the first completes.
post /repos/{owner}/{repo}/pages/builds
パラメータ
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path |
コードサンプル
Shell
curl \
-X POST \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/pages/builds
JavaScript (@octokit/core.js)
await octokit.request('POST /repos/{owner}/{repo}/pages/builds', {
owner: 'octocat',
repo: 'hello-world'
})
Response
Status: 201 Created
{
"url": "https://api.github.com/repos/github/developer.github.com/pages/builds/latest",
"status": "queued"
}
Notes
get /repos/{owner}/{repo}/pages/builds/latest
パラメータ
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path |
コードサンプル
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/pages/builds/latest
JavaScript (@octokit/core.js)
await octokit.request('GET /repos/{owner}/{repo}/pages/builds/latest', {
owner: 'octocat',
repo: 'hello-world'
})
Response
Status: 200 OK
{
"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"
}
Notes
get /repos/{owner}/{repo}/pages/builds/{build_id}
パラメータ
Name | Type | In | Description |
---|---|---|---|
accept |
string | header |
Setting to
|
owner |
string | path | |
repo |
string | path | |
build_id |
integer | path |
コードサンプル
Shell
curl \
-H "Accept: application/vnd.github.v3+json" \
http(s)://{hostname}/api/v3/repos/octocat/hello-world/pages/builds/42
JavaScript (@octokit/core.js)
await octokit.request('GET /repos/{owner}/{repo}/pages/builds/{build_id}', {
owner: 'octocat',
repo: 'hello-world',
build_id: 42
})
Response
Status: 200 OK
{
"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"
}