Public/Set-GitHubEnvironmentVariable.ps1
|
function Set-GitHubEnvironmentVariable { [CmdletBinding(SupportsShouldProcess)] param( [Parameter(Mandatory)] [ValidateNotNullOrEmpty()] [string] $Name, [AllowNull()] [object] $Value ) if ($Name -eq 'NODE_OPTIONS') { throw 'GitHub Actions does not allow NODE_OPTIONS to be set with GITHUB_ENV.' } if ($Name -cmatch '^(GITHUB|RUNNER)_') { throw 'GitHub Actions does not allow GITHUB_* or RUNNER_* environment variables to be overwritten with GITHUB_ENV.' } if ($PSCmdlet.ShouldProcess($Name, 'Write GitHub Actions environment variable to GITHUB_ENV')) { Add-GitHubEnvironmentFileEntryInternal -VariableName 'GITHUB_ENV' -Name $Name -Value $Value } } |