Skip to content

Commit

Permalink
updating for removal of set-env and add-path commands
Browse files Browse the repository at this point in the history
  • Loading branch information
ebekker committed Nov 19, 2020
1 parent 86041cc commit a40372a
Showing 1 changed file with 34 additions and 4 deletions.
38 changes: 34 additions & 4 deletions lib/ActionsCore.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ function Set-ActionVariable {
}

## To take effect for all subsequent actions/steps
Send-ActionCommand set-env @{
name = $Name
} -Message $Value
Write-ActionEnvVariable -Name $Name -Value $Value
}

<#
Expand Down Expand Up @@ -70,7 +68,7 @@ function Add-ActionPath {
}

## To take effect for all subsequent actions/steps
Send-ActionCommand add-path $Path
Write-ActionEnvPath -Path $Path
}

## Used to identify inputs from env vars in Action/Workflow context
Expand Down Expand Up @@ -313,6 +311,38 @@ function Send-ActionCommand {
return $cmdStr
}

function Write-ActionEnvVariable {
param(
[Parameter(Position=0, Mandatory)]
[string]$Name,
[Parameter(Position=1, Mandatory)]
[string]$Value,

[nullable[bool]]$Multiline
)

if ($Multiline -eq $null) {
$Multiline = $Value.Contains("`r") -or $Value.Contains("`n")
}

if ($Multiline) {
$delim = [Guid]::NewGuid().ToString().Replace('-', '')
Add-Content -Encoding utf8NoBOM -Path $env:GITHUB_ENV -Value "$($Name)<<$($delim)`n$($Value)`n$($delim)"
}
else {
Add-Content -Encoding utf8NoBOM -Path $env:GITHUB_ENV -Value "$($Name)=$($Value)"
}
}

function Write-ActionEnvPath {
param(
[Parameter(Position=0, Mandatory)]
[string]$Path
)

Add-Content -Encoding utf8NoBOM -Path $env:GITHUB_PATH -Value $Path
}

function ConvertTo-EscapedData {
param(
[Parameter(Mandatory)]
Expand Down

0 comments on commit a40372a

Please sign in to comment.