add github variable helpers (credit: @microsoft)

This commit is contained in:
David Refoua 2022-10-15 15:37:39 +03:30 committed by GitHub
parent 473e9566e7
commit a49921bb1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -67,6 +67,31 @@ function Digest-Hash($path) {
return Invoke-Expression "md5sum $path" return Invoke-Expression "md5sum $path"
} }
function Set-GHVariable {
param(
[Parameter(Mandatory = $true)]
[string]$Name,
[Parameter(Mandatory = $true)]
[string]$Value
)
Write-Verbose "Setting CI variable $Name to $Value" -Verbose
if ($env:GITHUB_ENV) {
"$Name=$Value" | Out-File $env:GITHUB_ENV -Append
}
}
function Get-GHTempPath {
$temp = [System.IO.Path]::GetTempPath()
if ($env:RUNNER_TEMP) {
$temp = $env:RUNNER_TEMP
}
Write-Verbose "Get CI Temp path: $temp" -Verbose
return $temp
}
function Get-VersionStr() { function Get-VersionStr() {
# Clear existing variable # Clear existing variable
if ($string) { Clear-Variable -name string } if ($string) { Clear-Variable -name string }