{"meta":{"title":"배포에 대한 REST API 엔드포인트","intro":"REST API를 사용하여 배포 및 배포 환경을 만들고 삭제합니다.","product":"REST API","breadcrumbs":[{"href":"/ko/enterprise-server@3.21/rest","title":"REST API"},{"href":"/ko/enterprise-server@3.21/rest/deployments","title":"배포"},{"href":"/ko/enterprise-server@3.21/rest/deployments/deployments","title":"배포"}],"documentType":"article"},"body":"# 배포에 대한 REST API 엔드포인트\n\nREST API를 사용하여 배포 및 배포 환경을 만들고 삭제합니다.\n\n## 배포에 대해\n\n배포는 특정 참조(분기, SHA, 태그)를 배포하기 위한 요청입니다. GitHub 외부 서비스가 새 배포를 만들 때 수신 대기하고 조치를 수행할 수 있는 [`deployment` 이벤트](/ko/enterprise-server@3.21/webhooks/webhook-events-and-payloads#deployment)를 디스패치합니다. 배포를 통해 개발자와 조직은 다양한 유형의 애플리케이션(예: 웹, 네이티브)을 제공하는 구현 세부 정보에 대해 걱정할 필요 없이 배포를 중심으로 느슨하게 결합된 도구를 빌드할 수 있습니다.\n\n배포 상태를 통해 외부 서비스는 <c7><c6 /> 이벤트를 수신 대기하는 시스템이 사용할 수 있도록 배포를 <c0 />, <c1 />, <c2 />, <c3 />, <c4 />, 또는 <c5 /> 상태로 표시할 수 있습니다.\n\n배포 상태에는 배포 상태를 더 유용하게 하므로 매우 권장되는 선택 사항인 `description` 및 `log_url`도 포함할 수 있습니다.\n`log_url`은 배포 출력에 대한 전체 URL이고 `description`은 배포에서 발생한 일에 대한 상위 수준 요약입니다.\n\nGitHub 새 배포 및 배포 상태가 생성되면 `deployment` 및 `deployment_status` 이벤트를 디스패치합니다. 이러한 이벤트를 통해 타사 통합이 배포 요청에 대한 응답을 수신하고 진행 상황에 따라 배포 상태를 업데이트할 수 있습니다.\n\n다음은 이러한 상호 작용이 작동하는 방식에 대한 간단한 시퀀스 다이어그램입니다.\n\n```text\n+---------+             +--------+            +-----------+        +-------------+\n| Tooling |             | GitHub |            | 3rd Party |        | Your Server |\n+---------+             +--------+            +-----------+        +-------------+\n     |                      |                       |                     |\n     |  Create Deployment   |                       |                     |\n     |--------------------->|                       |                     |\n     |                      |                       |                     |\n     |  Deployment Created  |                       |                     |\n     |<---------------------|                       |                     |\n     |                      |                       |                     |\n     |                      |   Deployment Event    |                     |\n     |                      |---------------------->|                     |\n     |                      |                       |     SSH+Deploys     |\n     |                      |                       |-------------------->|\n     |                      |                       |                     |\n     |                      |   Deployment Status   |                     |\n     |                      |<----------------------|                     |\n     |                      |                       |                     |\n     |                      |                       |   Deploy Completed  |\n     |                      |                       |<--------------------|\n     |                      |                       |                     |\n     |                      |   Deployment Status   |                     |\n     |                      |<----------------------|                     |\n     |                      |                       |                     |\n```\n\nGitHub 실제로 서버에 액세스하지 않습니다. 배포 이벤트와 상호 작용하는 것은 타사 통합에 달려 있습니다. 여러 시스템이 배포 이벤트를 수신 대기할 수 있으며 서버에 코드를 푸시하고 네이티브 코드를 빌드하는 등의 책임이 있는지 여부에 대한 결정은 각 시스템에 달려 있습니다.\n\n`repo_deployment`\n[OAuth 범위](/ko/enterprise-server@3.21/apps/oauth-apps/building-oauth-apps/scopes-for-oauth-apps)는 리포지토리 코드에 대한 액세스 권한을 부여하지 **않고** 배포 및 배포 상태에 대한 특정 액세스 권한만을 제공합니다. 반면에 `public_repo` 및 `repo` 범위에는 코드에 대한 권한도 포함됩니다.\n\n### 비활성화된 배포\n\n배포 상태를 `success`로 설정하면 동일한 환경 이름이 있는 동일한 리포지토리에서 이전의 모든 영구 비프로덕션 환경 배포가 `inactive`됩니다. 이를 방지하려면 배포 상태를 만들 때 `auto_inactive`를 `false`로 설정할 수 있습니다.\n\n`state`를 `inactive`로 설정하여 임시 환경이 더 이상 존재하지 않음을 알릴 수 있습니다.\n`state`를 `inactive`(으)로 설정하면 `destroyed`에서 배포가 GitHub(으)로 표시되며 해당 배포에 대한 액세스 권한이 제거됩니다.\n\n> \\[!NOTE]\n> Most endpoints use `Authorization: Bearer <YOUR-TOKEN>` and `Accept: application/vnd.github+json` headers, plus `X-GitHub-Api-Version: 2026-03-10`. Curl examples below omit these standard headers for brevity.\n\n## List deployments\n\n```\nGET /repos/{owner}/{repo}/deployments\n```\n\nSimple filtering of deployments is available via query parameters:\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n* **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n* **`sha`** (string)\n  The SHA recorded at creation time.\n  Default: `none`\n\n* **`ref`** (string)\n  The name of the ref. This can be a branch, tag, or SHA.\n  Default: `none`\n\n* **`task`** (string)\n  The name of the task for the deployment (e.g., deploy or deploy:migrations).\n  Default: `none`\n\n* **`environment`** (string,null)\n  The name of the environment that was deployed to (e.g., staging or production).\n  Default: `none`\n\n* **`per_page`** (integer)\n  The number of results per page (max 100). For more information, see \"Using pagination in the REST API.\"\n  Default: `30`\n\n* **`page`** (integer)\n  The page number of the results to fetch. For more information, see \"Using pagination in the REST API.\"\n  Default: `1`\n\n### HTTP response status codes\n\n* **200** - OK\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/deployments\n```\n\n**Response schema (Status: 200):**\n\nArray of `Deployment`:\n\n* `url`: required, string, format: uri\n* `id`: required, integer, format: int64\n* `node_id`: required, string\n* `sha`: required, string\n* `ref`: required, string\n* `task`: required, string\n* `payload`: required, one of:\n  * **object, additional properties allowed**\n  * **string**\n* `original_environment`: string\n* `environment`: required, string\n* `description`: required, string or null\n* `creator`: required, any of:\n  * **null**\n  * **Simple User**\n    * `name`: string or null\n    * `email`: string or null\n    * `login`: required, string\n    * `id`: required, integer, format: int64\n    * `node_id`: required, string\n    * `avatar_url`: required, string, format: uri\n    * `gravatar_id`: required, string or null\n    * `url`: required, string, format: uri\n    * `html_url`: required, string, format: uri\n    * `followers_url`: required, string, format: uri\n    * `following_url`: required, string\n    * `gists_url`: required, string\n    * `starred_url`: required, string\n    * `subscriptions_url`: required, string, format: uri\n    * `organizations_url`: required, string, format: uri\n    * `repos_url`: required, string, format: uri\n    * `events_url`: required, string\n    * `received_events_url`: required, string, format: uri\n    * `type`: required, string\n    * `site_admin`: required, boolean\n    * `starred_at`: string\n    * `user_view_type`: string\n* `created_at`: required, string, format: date-time\n* `updated_at`: required, string, format: date-time\n* `statuses_url`: required, string, format: uri\n* `repository_url`: required, string, format: uri\n* `transient_environment`: boolean\n* `production_environment`: boolean\n* `performed_via_github_app`: any of:\n  * **null**\n  * **GitHub app**\n    * `id`: required, integer\n    * `slug`: string\n    * `node_id`: required, string\n    * `client_id`: string\n    * `owner`: required, one of:\n      * **Simple User** (see above)\n      * **Enterprise**\n        * `description`: string or null\n        * `html_url`: required, string, format: uri\n        * `website_url`: string or null, format: uri\n        * `id`: required, integer\n        * `node_id`: required, string\n        * `name`: required, string\n        * `slug`: required, string\n        * `created_at`: required, string or null, format: date-time\n        * `updated_at`: required, string or null, format: date-time\n        * `avatar_url`: required, string, format: uri\n    * `name`: required, string\n    * `description`: required, string or null\n    * `external_url`: required, string, format: uri\n    * `html_url`: required, string, format: uri\n    * `created_at`: required, string, format: date-time\n    * `updated_at`: required, string, format: date-time\n    * `permissions`: required, object, additional properties: string:\n      * `issues`: string\n      * `checks`: string\n      * `metadata`: string\n      * `contents`: string\n      * `deployments`: string\n    * `events`: required, array of string\n    * `installations_count`: integer\n\n## Create a deployment\n\n```\nPOST /repos/{owner}/{repo}/deployments\n```\n\nDeployments offer a few configurable parameters with certain defaults.\nThe ref parameter can be any named branch, tag, or SHA. At GitHub Enterprise Server we often deploy branches and verify them\nbefore we merge a pull request.\nThe environment parameter allows deployments to be issued to different runtime environments. Teams often have\nmultiple environments for verifying their applications, such as production, staging, and qa. This parameter\nmakes it easier to track which environments have requested deployments. The default environment is production.\nThe auto\\_merge parameter is used to ensure that the requested ref is not behind the repository's default branch. If\nthe ref is behind the default branch for the repository, we will attempt to merge it for you. If the merge succeeds,\nthe API will return a successful merge commit. If merge conflicts prevent the merge from succeeding, the API will\nreturn a failure response.\nBy default, commit statuses for every submitted context must be in a success\nstate. The required\\_contexts parameter allows you to specify a subset of contexts that must be success, or to\nspecify contexts that have not yet been submitted. You are not required to use commit statuses to deploy. If you do\nnot require any contexts or create any commit statuses, the deployment will always succeed.\nThe payload parameter is available for any extra information that a deployment system might need. It is a JSON text\nfield that will be passed on when a deployment event is dispatched.\nThe task parameter is used by the deployment system to allow different execution paths. In the web world this might\nbe deploy:migrations to run schema changes on the system. In the compiled world this could be a flag to compile an\napplication with debugging enabled.\nMerged branch response:\nYou will see this response when GitHub automatically merges the base branch into the topic branch instead of creating\na deployment. This auto-merge happens when:\n\nAuto-merge option is enabled in the repository\nTopic branch does not include the latest changes on the base branch, which is master in the response example\nThere are no merge conflicts\n\nIf there are no new commits in the base branch, a new request to create a deployment should give a successful\nresponse.\nMerge conflict response:\nThis error happens when the auto\\_merge option is enabled and when the default branch (in this case master), can't\nbe merged into the branch that's being deployed (in this case topic-branch), due to merge conflicts.\nFailed commit status checks:\nThis error happens when the required\\_contexts parameter indicates that one or more contexts need to have a success\nstatus for the commit to be deployed, but one or more of the required contexts do not have a state of success.\nOAuth app tokens and personal access tokens (classic) need the repo or repo\\_deployment scope to use this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n* **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n#### Body parameters\n\n* **`ref`** (string) (required)\n  The ref to deploy. This can be a branch, tag, or SHA.\n\n* **`task`** (string)\n  Specifies a task to execute (e.g., deploy or deploy:migrations).\n  Default: `deploy`\n\n* **`auto_merge`** (boolean)\n  Attempts to automatically merge the default branch into the requested ref, if it's behind the default branch.\n  Default: `true`\n\n* **`required_contexts`** (array of strings)\n  The status contexts to verify against commit status checks. If you omit this parameter, GitHub verifies all unique contexts before creating a deployment. To bypass checking entirely, pass an empty array. Defaults to all unique contexts.\n\n* **`payload`** (object or string)\n  JSON payload with extra information about the deployment.\n\n* **`environment`** (string)\n  Name for the target deployment environment (e.g., production, staging, qa).\n  Default: `production`\n\n* **`description`** (string or null)\n  Short description of the deployment.\n  Default: \\`\\`\n\n* **`transient_environment`** (boolean)\n  Specifies if the given environment is specific to the deployment and will no longer exist at some point in the future. Default: false\n  Default: `false`\n\n* **`production_environment`** (boolean)\n  Specifies if the given environment is one that end-users directly interact with. Default: true when environment is production and false otherwise.\n\n### HTTP response status codes\n\n* **201** - Created\n\n* **202** - Merged branch response\n\n* **409** - Conflict when there is a merge conflict or the commit's status checks failed\n\n* **422** - Validation failed, or the endpoint has been spammed.\n\n### Code examples\n\n#### Simple example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X POST \\\n  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/deployments \\\n  -d '{\n  \"ref\": \"topic-branch\",\n  \"payload\": \"{ \\\"deploy\\\": \\\"migrate\\\" }\",\n  \"description\": \"Deploy request from hubot\"\n}'\n```\n\n**Response schema (Status: 201):**\n\n* `url`: required, string, format: uri\n* `id`: required, integer, format: int64\n* `node_id`: required, string\n* `sha`: required, string\n* `ref`: required, string\n* `task`: required, string\n* `payload`: required, one of:\n  * **object, additional properties allowed**\n  * **string**\n* `original_environment`: string\n* `environment`: required, string\n* `description`: required, string or null\n* `creator`: required, any of:\n  * **null**\n  * **Simple User**\n    * `name`: string or null\n    * `email`: string or null\n    * `login`: required, string\n    * `id`: required, integer, format: int64\n    * `node_id`: required, string\n    * `avatar_url`: required, string, format: uri\n    * `gravatar_id`: required, string or null\n    * `url`: required, string, format: uri\n    * `html_url`: required, string, format: uri\n    * `followers_url`: required, string, format: uri\n    * `following_url`: required, string\n    * `gists_url`: required, string\n    * `starred_url`: required, string\n    * `subscriptions_url`: required, string, format: uri\n    * `organizations_url`: required, string, format: uri\n    * `repos_url`: required, string, format: uri\n    * `events_url`: required, string\n    * `received_events_url`: required, string, format: uri\n    * `type`: required, string\n    * `site_admin`: required, boolean\n    * `starred_at`: string\n    * `user_view_type`: string\n* `created_at`: required, string, format: date-time\n* `updated_at`: required, string, format: date-time\n* `statuses_url`: required, string, format: uri\n* `repository_url`: required, string, format: uri\n* `transient_environment`: boolean\n* `production_environment`: boolean\n* `performed_via_github_app`: any of:\n  * **null**\n  * **GitHub app**\n    * `id`: required, integer\n    * `slug`: string\n    * `node_id`: required, string\n    * `client_id`: string\n    * `owner`: required, one of:\n      * **Simple User** (see above)\n      * **Enterprise**\n        * `description`: string or null\n        * `html_url`: required, string, format: uri\n        * `website_url`: string or null, format: uri\n        * `id`: required, integer\n        * `node_id`: required, string\n        * `name`: required, string\n        * `slug`: required, string\n        * `created_at`: required, string or null, format: date-time\n        * `updated_at`: required, string or null, format: date-time\n        * `avatar_url`: required, string, format: uri\n    * `name`: required, string\n    * `description`: required, string or null\n    * `external_url`: required, string, format: uri\n    * `html_url`: required, string, format: uri\n    * `created_at`: required, string, format: date-time\n    * `updated_at`: required, string, format: date-time\n    * `permissions`: required, object, additional properties: string:\n      * `issues`: string\n      * `checks`: string\n      * `metadata`: string\n      * `contents`: string\n      * `deployments`: string\n    * `events`: required, array of string\n    * `installations_count`: integer\n\n## Get a deployment\n\n```\nGET /repos/{owner}/{repo}/deployments/{deployment_id}\n```\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n* **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n* **`deployment_id`** (integer) (required)\n  deployment\\_id parameter\n\n### HTTP response status codes\n\n* **200** - OK\n\n* **404** - Resource not found\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X GET \\\n  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/deployments/DEPLOYMENT_ID\n```\n\n**Response schema (Status: 200):**\n\nSame response schema as [Create a deployment](#create-a-deployment).\n\n## Delete a deployment\n\n```\nDELETE /repos/{owner}/{repo}/deployments/{deployment_id}\n```\n\nIf the repository only has one deployment, you can delete the deployment regardless of its status. If the repository has more than one deployment, you can only delete inactive deployments. This ensures that repositories with multiple deployments will always have an active deployment.\nTo set a deployment as inactive, you must:\n\nCreate a new deployment that is active so that the system has a record of the current state, then delete the previously active deployment.\nMark the active deployment as inactive by adding any non-successful deployment status.\n\nFor more information, see \"Create a deployment\" and \"Create a deployment status.\"\nOAuth app tokens and personal access tokens (classic) need the repo or repo\\_deployment scope to use this endpoint.\n\n### Parameters\n\n#### Headers\n\n* **`accept`** (string)\n  Setting to `application/vnd.github+json` is recommended.\n\n#### Path and query parameters\n\n* **`owner`** (string) (required)\n  The account owner of the repository. The name is not case sensitive.\n\n* **`repo`** (string) (required)\n  The name of the repository without the .git extension. The name is not case sensitive.\n\n* **`deployment_id`** (integer) (required)\n  deployment\\_id parameter\n\n### HTTP response status codes\n\n* **204** - No Content\n\n* **404** - Resource not found\n\n* **422** - Validation failed, or the endpoint has been spammed.\n\n### Code examples\n\n#### Example\n\n**Request:**\n\n```curl\ncurl -L \\\n  -X DELETE \\\n  http(s)://HOSTNAME/api/v3/repos/OWNER/REPO/deployments/DEPLOYMENT_ID\n```\n\n**Response schema (Status: 204):**"}