Skip to content

Set-GitHubSecret

SYNOPSIS

Updates a GitHub secret for an organization, repository, or user.

SYNTAX

Organization (Default)

Set-GitHubSecret -Owner <string> -Name <string> [-Value <Object>] [-Visibility <string>]
 [-SelectedRepositories <ulong[]>] [-Context <Object>] [-WhatIf] [-Confirm] [<CommonParameters>]

Environment

Set-GitHubSecret -Owner <string> -Repository <string> -Environment <string> -Name <string>
 [-Value <Object>] [-Context <Object>] [-WhatIf] [-Confirm] [<CommonParameters>]

Repository

Set-GitHubSecret -Owner <string> -Repository <string> -Name <string> [-Value <Object>]
 [-Context <Object>] [-WhatIf] [-Confirm] [<CommonParameters>]

ALIASES

This cmdlet has the following aliases, {{Insert list of aliases}}

DESCRIPTION

This function updates a secret in a GitHub repository, environment, or organization. It encrypts the secret value before storing it and supports different visibility levels.

EXAMPLES

EXAMPLE 1

$secret = ConvertTo-SecureString "my-secret-value" -AsPlainText -Force
Set-GitHubSecret -Repository 'MyRepo' -Owner 'MyUser' -Name 'MySecret' -Value $secret

Updates the secret MySecret in the MyRepo repository for the owner MyUser.

EXAMPLE 2

$params = @{
    Organization = 'MyOrg'
    Name         = 'MySecret'
    Type         = 'actions'
    Value        = (ConvertTo-SecureString "my-secret-value" -AsPlainText -Force)
    Visibility   = 'Private'
}
Set-GitHubSecret @params

Updates the secret MySecret at the organization level for GitHub Actions, setting visibility to private.

EXAMPLE 3

$params = @{
    Owner       = 'MyUser'
    Repository  = 'MyRepo'
    Environment = 'Production'
    Name        = 'MySecret'
    Value       = (ConvertTo-SecureString "my-secret-value" -AsPlainText -Force)
}
Set-GitHubSecret @params

Updates the secret MySecret in the Production environment of the MyRepo repository for MyUser.

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: ''

-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 secret to be updated.

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 secret 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 secret value to be stored, as a SecureString or a plain string (less secure).

Type: System.Object
DefaultValue: (Read-Host -AsSecureString -Prompt 'Enter the secret value')
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 secret when updating an organization secret. 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

GitHubSecret

{{ Fill in the Description }}

NOTES