Skip to content

Set-GitHubOutput

SYNOPSIS

Sets the GitHub output for a given key and value.

SYNTAX

Set-GitHubOutput [-Name] <String> [-Value] <Object> [[-Path] <String>] [-ProgressAction <ActionPreference>]
 [-WhatIf] [-Confirm] [<CommonParameters>]

DESCRIPTION

This function appends key-value pairs to the GitHub Actions output file specified by $env:GITHUB_OUTPUT. It handles two scenarios: - Normal shell execution: Appends the key-value pair directly. - GitHub composite action via GitHub-Script: Accumulates key-value pairs under the 'result' key as a JSON object.

EXAMPLES

EXAMPLE 1

Set-GitHubOutput -Name 'ID' -Value '123123123'

Sets the output variable 'ID' to '123123123' in the GitHub Actions output file.

EXAMPLE 2

Set-GitHubOutput -Name 'result' -Value @{
    ID   = '123123123'
    name = 'test'
}

PARAMETERS

-Name

The name of the output variable to set.

Type: String
Parameter Sets: (All)
Aliases:

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

-Value

The value of the output variable to set.

Type: Object
Parameter Sets: (All)
Aliases:

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

-Path

The path to the GitHub output file.

Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: $env:GITHUB_OUTPUT
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

NOTES