New-GitHubRepositoryDeployment

SYNOPSIS

Create a deployment

SYNTAX

Default (Default)

New-GitHubRepositoryDeployment [-Owner] <string> [-Repo] <string> -Ref <string> [-Task <string>]
 [-AutoMerge] [-RequiredContexts <string[]>] [-Payload <Object>] [-Environment <string>]
 [-Description <string>] [-TransientEnvironment] [-ProductionEnvironment] [-Accept <string>]
 [-WhatIf] [-Confirm]

Body

New-GitHubRepositoryDeployment [-Owner] <string> [-Repo] <string> -Body <Object> [-Ref <string>]
 [-Task <string>] [-AutoMerge] [-RequiredContexts <string[]>] [-Payload <Object>]
 [-Environment <string>] [-Description <string>] [-TransientEnvironment] [-ProductionEnvironment]
 [-Accept <string>] [-WhatIf] [-Confirm]

ALIASES

This cmdlet has the following aliases,

  • Get-GHNewRepositoryDeployment

DESCRIPTION

The New-GitHubRepositoryDeployment cmdlet invokes the POST method of the /repos/{owner}/{repo}/deployments endpoint (Create a deployment)

Deployments offer a few configurable parameters with certain defaults.

The ‘ref’ parameter can be any named branch, tag, or SHA. At GitHub we often deploy branches and verify them before we merge a pull request.

The ‘environment’ parameter allows deployments to be issued to different runtime environments. Teams often have multiple environments for verifying their applications, such as ‘production’, ‘staging’, and ‘qa’. This parameter makes it easier to track which environments have requested deployments. The default environment is ‘production’.

The ‘auto_merge’ parameter is used to ensure that the requested ref is not behind the repository’s default branch. If the ref is behind the default branch for the repository, we will attempt to merge it for you. If the merge succeeds, the API will return a successful merge commit. If merge conflicts prevent the merge from succeeding, the API will return a failure response.

By default, commit statuses (https://docs.github.com/rest/commits/statuses) for every submitted context must be in a ‘success’ state. The ‘required_contexts’ parameter allows you to specify a subset of contexts that must be ‘success’, or to specify contexts that have not yet been submitted. You are not required to use commit statuses to deploy. If you do not require any contexts or create any commit statuses, the deployment will always succeed.

The ‘payload’ parameter is available for any extra information that a deployment system might need. It is a JSON text field that will be passed on when a deployment event is dispatched.

The ‘task’ parameter is used by the deployment system to allow different execution paths. In the web world this might be ‘deploy:migrations’ to run schema changes on the system. In the compiled world this could be a flag to compile an application with debugging enabled.

Merged branch response:

You will see this response when GitHub automatically merges the base branch into the topic branch instead of creating a deployment. This auto-merge happens when:

  • Auto-merge option is enabled in the repository
  • Topic branch does not include the latest changes on the base branch, which is ‘master’ in the response example
  • There are no merge conflicts

If there are no new commits in the base branch, a new request to create a deployment should give a successful response.

Merge conflict response:

This error happens when the ‘auto_merge’ option is enabled and when the default branch (in this case ‘master’), can’t be merged into the branch that’s being deployed (in this case ‘topic-branch’), due to merge conflicts.

Failed commit status checks:

This error happens when the ‘required_contexts’ parameter indicates that one or more contexts need to have a ‘success’ status for the commit to be deployed, but one or more of the required contexts do not have a state of ‘success’.

OAuth app tokens and personal access tokens (classic) need the ‘repo’ or ‘repo_deployment’ scope to use this endpoint.

Endpoint: POST /repos/{owner}/{repo}/deployments API version: 2026-03-10

EXAMPLES

EXAMPLE 1

New-GitHubRepositoryDeployment -Owner 'octocat' -Repo 'Hello-World' -Ref 'topic-branch' -Body @{ key = 'value' }

Invokes POST /repos/{owner}/{repo}/deployments

EXAMPLE 2

New-GitHubRepositoryDeployment -Owner 'octocat' -Repo 'Hello-World' -Body @{ ref = 'topic-branch' }

Sends the request body from a hashtable, parameters override the keys of -Body

PARAMETERS

-Accept

The Accept header (media type) of the request Default value: application/vnd.github+json

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-AutoMerge

Attempts to automatically merge the default branch into the requested ref, if it’s behind the default branch.

Body property [ auto_merge ]

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Body

The whole request body as a hashtable or object. Keys that are also available as parameters are overwritten by the parameter values

Type: System.Object
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Body
  Position: Named
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: System.Management.Automation.SwitchParameter
DefaultValue: ''
SupportsWildcards: false
Aliases:
- cf
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Description

Short description of the deployment.

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Environment

Name for the target deployment environment (e.g., ‘production’, ‘staging’, ‘qa’).

Default value: production

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Owner

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

Path parameter [ owner ]

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 0
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Payload

JSON payload with extra information about the deployment.

Type: System.Object
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-ProductionEnvironment

Specifies if the given environment is one that end-users directly interact with. Default: ‘true’ when ‘environment’ is ‘production’ and ‘false’ otherwise.

Body property [ production_environment ]

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Ref

The ref to deploy. This can be a branch, tag, or SHA.

Required unless -Body is used

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Body
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
- Name: Default
  Position: Named
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Repo

The name of the repository without the ‘.git’ extension. The name is not case sensitive.

Path parameter [ repo ]

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: 1
  IsRequired: true
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: true
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-RequiredContexts

The status (https://docs.github.com/rest/commits/statuses) 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.

Body property [ required_contexts ]

Type: System.String[]
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-Task

Specifies a task to execute (e.g., ‘deploy’ or ‘deploy:migrations’).

Default value: deploy

Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-TransientEnvironment

Specifies if the given environment is specific to the deployment and will no longer exist at some point in the future. Default: ‘false’

Body property [ transient_environment ]

Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

-WhatIf

Runs the command in a mode that only reports what would happen without performing the actions.

Type: System.Management.Automation.SwitchParameter
DefaultValue: ''
SupportsWildcards: false
Aliases:
- wi
ParameterSets:
- Name: (All)
  Position: Named
  IsRequired: false
  ValueFromPipeline: false
  ValueFromPipelineByPropertyName: false
  ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

Objects with properties named like the path parameters can be piped to this function

{{ Fill in the Description }}

System.String

{{ Fill in the Description }}

OUTPUTS

The response of the GitHub API (objects

{{ Fill in the Description }}

NOTES

OperationId: repos/create-deployment Category: deployments / deployments