-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
action.ps1
29 lines (25 loc) · 960 Bytes
/
action.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env pwsh
Import-Module $PSScriptRoot/lib/GitHubActionsCore
function Private:CreateContext($name) {
$varName = "PWSH_SCRIPT_ACTION_$($name.ToUpper())"
$value = (Get-ChildItem "Env:$varName" -ErrorAction:SilentlyContinue).Value
$ctx = "$value" | ConvertFrom-Json -AsHashtable -NoEnumerate
Set-Variable -Name $name -Value $ctx -Scope Script -Option Constant
}
Private:CreateContext github
Private:CreateContext job
Private:CreateContext runner
Private:CreateContext strategy
Private:CreateContext matrix
try {
$Private:scriptFile = New-Item (Join-Path $env:TEMP "$(New-Guid).ps1") -ItemType File
Set-Content $Private:scriptFile "$env:PWSH_SCRIPT_ACTION_TEXT"
$Private:result = Invoke-Expression $Private:scriptFile
Set-ActionOutput 'result' $Private:result
}
catch {
Set-ActionOutput 'error' $_.ToString()
$ErrorView = 'NormalView'
Set-ActionFailed ($_ | Out-String)
}
exit [System.Environment]::ExitCode