Set-GitHubEnvironment¶
SYNOPSIS¶
Create or update an environment.
SYNTAX¶
Default (Default)¶
Set-GitHubEnvironment -Owner <string> -Repository <string> -Name <string> [-WaitTimer <int>]
[-DeploymentBranchPolicy <string>] [-Context <Object>] [-WhatIf] [-Confirm] [<CommonParameters>]
WithReviewers¶
Set-GitHubEnvironment -Owner <string> -Repository <string> -Name <string> -Reviewers <array>
[-WaitTimer <int>] [-PreventSelfReview] [-DeploymentBranchPolicy <string>] [-Context <Object>]
[-WhatIf] [-Confirm] [<CommonParameters>]
ALIASES¶
This cmdlet has the following aliases, {{Insert list of aliases}}
DESCRIPTION¶
Create or update an environment with protection rules, such as required reviewers. For more information about environment protection rules, see "Environments."
To create or update name patterns that branches must match in order to deploy to this environment, see "Deployment branch policies."
To create or update secrets for an environment, see "GitHub Actions secrets."
OAuth app tokens and personal access tokens (classic) need the repo scope to use this endpoint.
EXAMPLES¶
EXAMPLE 1¶
$params = @{
Owner = "my-org"
Repository = "my-repo"
Name = "staging"
WaitTimer = 30
Reviewers = @{ type = $user.Type; id = $user.ID }, @{ type = 'team'; id = $team.ID }
DeploymentBranchPolicy = 'CustomBranchPolicies'
}
Set-GitHubEnvironment @params
Output:
id : 5944178128
node_id : EN_kwDOOJqfM88AAAABYkz10A
name : test
url : https://api.github.com/repos/PSModule/EnvironmentTest/environments/test
html_url : https://github.com/PSModule/EnvironmentTest/deployments/activity_log?environments_filter=test
created_at : 3/16/2025 11:17:52 PM
updated_at : 3/16/2025 11:17:52 PM
can_admins_bypass : True
protection_rules : {@{id=30352888; node_id=GA_kwDOOJqfM84BzyX4; type=required_reviewers; prevent_self_review=False;
reviewers=System.Object[]},@{id=30352889; node_id=GA_kwDOOJqfM84BzyX5; type=wait_timer; wait_timer=100},
@{id=30352890; node_id=GA_kwDOOJqfM84BzyX6; type=branch_policy}}
deployment_branch_policy : @{protected_branches=False; custom_branch_policies=True}
Creates or updates the "staging" environment with a 30-minute wait timer.
PARAMETERS¶
-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: ''
-Context¶
The context to run the command in. Used to get the details for the API call. Can be either a string or a GitHubContext object.
Type: System.Object
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-DeploymentBranchPolicy¶
The type of deployment branch policy for this environment.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases:
- deployment_branch_policy
ParameterSets:
- Name: WithReviewers
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
- Name: Default
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Name¶
The name of the environment.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: WithReviewers
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
- Name: Default
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Owner¶
The name of the organization.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases:
- Organization
- User
ParameterSets:
- Name: WithReviewers
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
- Name: Default
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-PreventSelfReview¶
Whether or not a user who created the job is prevented from approving their own job.
Type: System.Management.Automation.SwitchParameter
DefaultValue: False
SupportsWildcards: false
Aliases:
- prevent_self_review
ParameterSets:
- Name: WithReviewers
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Repository¶
The name of the Repository.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: WithReviewers
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
- Name: Default
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Reviewers¶
The people or teams that may review jobs that reference the environment. Must be an object with the following properties: - ID: The ID of the user or team. - Type: The type of reviewer. Can be either 'User' or 'Team'. Example: $Reviewers = @( @{ ID = 123456789; Type = 'User' }, @{ ID = 987654321; Type = 'Team' } )
Type: System.Array
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: WithReviewers
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-WaitTimer¶
The amount of time to delay a job after the job is initially triggered. The time (in minutes) must be an integer between 0 and 43,200 (30 days).
Type: System.Int32
DefaultValue: 0
SupportsWildcards: false
Aliases:
- wait_timer
ParameterSets:
- Name: WithReviewers
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
- Name: Default
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
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¶
System.String¶
{{ Fill in the Description }}
System.Int32¶
{{ Fill in the Description }}
System.Array¶
{{ Fill in the Description }}
System.Management.Automation.SwitchParameter¶
{{ Fill in the Description }}
OUTPUTS¶
GitHubEnvironment¶
{{ Fill in the Description }}
NOTES¶
Create or update an environment