Skip to content

Update-GitHubVariable

SYNOPSIS

Update a GitHub variable at the organization, repository, or environment level.

SYNTAX

Environment

Update-GitHubVariable -Owner <String> -Repository <String> -Environment <String> -Name <String>
 [-NewName <String>] [-Value <String>] [-PassThru] [-Context <Object>] [-ProgressAction <ActionPreference>]
 [-WhatIf] [-Confirm] [<CommonParameters>]

Repository

Update-GitHubVariable -Owner <String> -Repository <String> -Name <String> [-NewName <String>] [-Value <String>]
 [-PassThru] [-Context <Object>] [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

Organization

Update-GitHubVariable -Owner <String> -Name <String> [-NewName <String>] [-Value <String>]
 [-Visibility <String>] [-SelectedRepositories <UInt64[]>] [-PassThru] [-Context <Object>]
 [-ProgressAction <ActionPreference>] [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

Updates a GitHub Actions variable that can be referenced in workflows. This function supports updating variables at different levels: organization, repository, or environment. It delegates the update process to the appropriate private function based on the specified parameters.

To modify an organization variable, users must have admin:org scope. Repository variables require repo scope, and environment variables require collaborator access.

EXAMPLES

EXAMPLE 1

Update-GitHubVariable -Owner 'octocat' -Repository 'Hello-World' -Name 'HOST_NAME' -Value 'github.com'

Updates the repository variable named HOST_NAME with the value github.com in the specified repository.

EXAMPLE 2

Update-GitHubVariable -Owner 'octocat' -Name 'HOST_NAME' -Value 'github.com' -Visibility 'private'

Updates the organization variable named HOST_NAME with the value github.com, making it private.

EXAMPLE 3

Update-GitHubVariable -Owner 'octocat' -Repository 'Hello-World' -Environment 'dev' -Name 'HOST_NAME' -Value 'github.com'

Updates the environment variable named HOST_NAME with the value github.com in the specified environment.

PARAMETERS

-Owner

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

Type: String
Parameter Sets: (All)
Aliases: Organization, User

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Repository

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

Type: String
Parameter Sets: Environment, Repository
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Environment

The name of the repository environment.

Type: String
Parameter Sets: Environment
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Name

The name of the variable.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-NewName

The new name of the variable.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Value

The value of the variable.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Visibility

The visibility of the variable when updating an organization variable. Can be private, selected, or all.

Type: String
Parameter Sets: Organization
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-SelectedRepositories

The IDs of the repositories to which the variable is available. Used only when the -Visibility parameter is set to selected.

Type: UInt64[]
Parameter Sets: Organization
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-PassThru

If specified, the function will return the updated variable object.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-Context

The context to run the command in. Can be either a string or a GitHubContext object.

Type: Object
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: (Get-GitHubContext)
Accept pipeline input: False
Accept wildcard characters: False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Confirm

Prompts you for confirmation before running the cmdlet.

Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-ProgressAction

{{ Fill ProgressAction Description }}

Type: ActionPreference
Parameter Sets: (All)
Aliases: proga

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

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

INPUTS

OUTPUTS

GitHubVariable

NOTES

Returns an GitHubVariable object containing details about the environment variable, including its name, value, associated repository, and environment details.

https://psmodule.io/GitHub/Functions/Variables/Update-GitHubVariable/