-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.ps1
58 lines (50 loc) · 2.02 KB
/
entrypoint.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
function Main()
{
[OutputType([Void])]
param ([string[]] $inputArgs)
# Remove any arg that is empty or whitespace. This removes empty strings that are passed from the action.yml.
# This is a workaround to deal with non-required action inputs when this script is called via the action.yml.
$argsAsList = [Collections.Generic.List[String]]::new()
foreach ($arg in $inputArgs)
{
if(![string]::IsNullOrWhiteSpace($arg))
{
$argsAsList.Add($arg)
}
}
$command = $inputArgs[0]
# The --auth-token and --repo have a default value set on the action.yml for ease of use.
# However, these options are only valid for the read-data-different-workflow command so
# we have to remove them if we are executing a different command or else the CLI will return an error.
if($command -ne "read-data-different-workflow")
{
$authTokenIdx = $argsAsList.IndexOf("--auth-token")
if($authTokenIdx -ne -1)
{
$authTokenOption = $argsAsList[$authTokenIdx]
$authTokenValue = $argsAsList[$authTokenIdx + 1]
$argsAsList.Remove($authTokenOption) | Out-Null # supress True from showing in the output. See https://devblogs.microsoft.com/powershell/suppressing-return-values-in-powershell-functions/
$argsAsList.Remove($authTokenValue) | Out-Null
}
$repoIdx = $argsAsList.IndexOf("--repo")
if($repoIdx -ne -1)
{
$repoOption = $argsAsList[$repoIdx]
$repoValue = $argsAsList[$repoIdx + 1]
$argsAsList.Remove($repoOption) | Out-Null
$argsAsList.Remove($repoValue) | Out-Null
}
}
Write-Output "Executing: dotnet '/app/ShareJobsDataCli.dll' $argsAsList"
$output = dotnet '/app/ShareJobsDataCli.dll' $argsAsList
if($LASTEXITCODE -ne 0 ) {
Write-Output "::error::Share data jobs didn't complete successfully. See the step's log for more details."
exit $LASTEXITCODE
}
Write-Output $output >> $env:GITHUB_OUTPUT
Write-Output "::group::Share jobs data output"
Write-Output $output
Write-Output "::endgroup::"
}
# invoke entrypoint function
Main $args