Set-GitHubVariable¶
SYNOPSIS¶
Creates or updates a GitHub Actions variable at the organization, repository, or environment level.
SYNTAX¶
Environment¶
Set-GitHubVariable -Owner <string> -Repository <string> -Environment <string> -Name <string>
[-Value <string>] [-Context <Object>] [-WhatIf] [-Confirm] [<CommonParameters>]
Repository¶
Set-GitHubVariable -Owner <string> -Repository <string> -Name <string> [-Value <string>]
[-Context <Object>] [-WhatIf] [-Confirm] [<CommonParameters>]
Organization¶
Set-GitHubVariable -Owner <string> -Name <string> [-Value <string>] [-Visibility <string>]
[-SelectedRepositories <ulong[]>] [-Context <Object>] [-WhatIf] [-Confirm] [<CommonParameters>]
ALIASES¶
This cmdlet has the following aliases, {{Insert list of aliases}}
DESCRIPTION¶
This function checks if a GitHub Actions variable exists at the specified level (organization, repository, or environment). If the variable exists, it updates it with the new value. If it does not exist, it creates a new variable.
- Organization-level variables require the
admin:orgscope for OAuth tokens and personal access tokens (classic). If the repository is private, thereposcope is also required. - Repository-level variables require the
reposcope. - Environment-level variables require collaborator access to the repository.
EXAMPLES¶
EXAMPLE 1¶
Set-GitHubVariable -Owner 'octocat' -Repository 'Hello-World' -Name 'HOST_NAME' -Value 'github.com' -Context $GitHubContext
Creates or updates a repository variable named HOST_NAME with the value github.com in the specified repository.
EXAMPLE 2¶
Set-GitHubVariable -Owner 'octocat' -Name 'HOST_NAME' -Value 'github.com' -Visibility 'all' -Context $GitHubContext
Creates or updates an organization variable named HOST_NAME with the value github.com and
makes it available to all repositories in the organization.
EXAMPLE 3¶
Set-GitHubVariable -Owner 'octocat' -Repository 'Hello-World' -Environment 'dev' -Name 'HOST_NAME' -Value 'github.com' -Context $GitHubContext
Creates or updates an environment variable named HOST_NAME with the value github.com in the specified environment.
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. 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: ''
-Environment¶
The name of the repository environment.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Environment
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Name¶
The name of the variable.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Owner¶
The account owner of the repository. The name is not case sensitive.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases:
- Organization
- User
ParameterSets:
- Name: Environment
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
- Name: Repository
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
- Name: Organization
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Repository¶
The name of the repository. The name is not case sensitive.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Environment
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
- Name: Repository
Position: Named
IsRequired: true
ValueFromPipeline: false
ValueFromPipelineByPropertyName: true
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-SelectedRepositories¶
The IDs of the repositories to which the variable is available.
Used only when the -Visibility parameter is set to selected.
Type: System.UInt64[]
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Organization
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Value¶
The value of the variable.
Type: System.String
DefaultValue: ''
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: (All)
Position: Named
IsRequired: false
ValueFromPipeline: false
ValueFromPipelineByPropertyName: false
ValueFromRemainingArguments: false
DontShow: false
AcceptedValues: []
HelpMessage: ''
-Visibility¶
The visibility of the variable when updating an organization variable.
Can be private, selected, or all.
Type: System.String
DefaultValue: Private
SupportsWildcards: false
Aliases: []
ParameterSets:
- Name: Organization
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¶
System.String¶
{{ Fill in the Description }}
OUTPUTS¶
GitHubVariable¶
{{ Fill in the Description }}
NOTES¶
Returns an GitHubVariable object containing details about the environment variable, including its name, value, associated repository, and environment details.