-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
69 lines (69 loc) · 2.39 KB
/
action.yml
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
59
60
61
62
63
64
65
66
67
68
69
# yaml-language-server: $schema=https://json.schemastore.org/github-action.json
name: "Setup PowerShell Toolkit"
author: "hugoalh Studio"
description: "Setup PowerShell module `hugoalh.GitHubActionsToolkit`."
inputs:
sudo:
description: "{Boolean} Whether to execute in sudo mode on non-Windows environment."
required: false
default: "False"
version:
description: "{String} Target version."
required: false
default: "^2.1.0"
allowprerelease:
description: "{Boolean} Whether to allow target pre release version."
required: false
default: "False"
scope:
description: "{String} Installation scope."
required: false
default: "CurrentUser"
force:
description: "{Boolean} Whether to force install or reinstall target (pre release) version."
required: false
default: "False"
keepsetting:
description: "{Boolean} Whether to keep the setting that modified."
required: false
default: "False"
outputs:
path:
description: "{String | Null} Path of the installation."
value: "${{steps.main.outputs.path}}"
version:
description: "{SemVer | Null} Version of the installation."
value: "${{steps.main.outputs.version}}"
runs:
using: "composite"
steps:
- name: "Main"
id: "main"
run: |
#Requires -PSEdition Core -Version 7.2
$Script:ErrorActionPreference = 'Stop'
Get-Alias -Scope 'Local' -ErrorAction 'SilentlyContinue' |
Remove-Alias -Scope 'Local' -Force -ErrorAction 'SilentlyContinue'
[String]$MainScriptPath = Join-Path -Path $Env:GITHUB_ACTION_PATH -ChildPath 'main.ps1'
If (!(Test-Path -LiteralPath $MainScriptPath -PathType 'Leaf')) {
Write-Host -Object '::error::Invalid script path!'
Exit 1
}
[Boolean]$InputSudo = [Boolean]::Parse($Env:INPUT_SUDO)
If ($InputSudo -and $Env:RUNNER_OS -iin @('Linux', 'MacOS')) {
sudo --non-interactive --preserve-env pwsh -NonInteractive $MainScriptPath
}
Else {
pwsh -NonInteractive $MainScriptPath
}
shell: "pwsh"
env:
INPUT_ALLOWPRERELEASE: "${{inputs.allowprerelease}}"
INPUT_FORCE: "${{inputs.force}}"
INPUT_KEEPSETTING: "${{inputs.keepsetting}}"
INPUT_SCOPE: "${{inputs.scope}}"
INPUT_SUDO: "${{inputs.sudo}}"
INPUT_VERSION: "${{inputs.version}}"
branding:
icon: "package"
color: "blue"