aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/action.yml
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-12-24 02:38:33 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-12-24 03:56:08 +0300
commitf38a95ebf90f50ae028252c6bd5c4ec5792f76a7 (patch)
tree365affdabc7f165a1c4844ab8f8a367e0e59e76c /action.yml
downloadcleanup-path-f38a95ebf90f50ae028252c6bd5c4ec5792f76a7.tar.gz
cleanup-path-f38a95ebf90f50ae028252c6bd5c4ec5792f76a7.zip
initial commit
Diffstat (limited to '')
-rw-r--r--action.yml49
1 files changed, 49 insertions, 0 deletions
diff --git a/action.yml b/action.yml
new file mode 100644
index 0000000..b262f8b
--- /dev/null
+++ b/action.yml
@@ -0,0 +1,49 @@
+name: Clean up %PATH%
+description: Clean up PATH environment variable on Windows workers
+
+inputs:
+ dirs:
+ description: Additional paths, separated by a semicolon (;)
+ required: false
+ default:
+ description: Add the default paths
+ required: false
+ default: 1
+
+runs:
+ using: composite
+ steps:
+ - run: |
+ New-Variable os -Value ('${{ runner.os }}') -Option Constant
+
+ New-Variable windows_host -Value ($os -eq 'Windows') -Option Constant
+
+ New-Variable dirs -Value ('${{ inputs.dirs }}') -Option Constant
+ New-Variable default -Value ('${{ inputs.default }}' -eq '1') -Option Constant
+
+ if ($windows_host) {
+ $sep = [IO.Path]::PathSeparator
+
+ $new_path = $dirs.Split($sep, [System.StringSplitOptions]::RemoveEmptyEntries)
+
+ if ($default) {
+ # This seems to be the default on new installations.
+ # Also, MSYS2 does this.
+ $new_path += @(
+ 'C:\Windows\system32',
+ 'C:\Windows',
+ 'C:\Windows\System32\Wbem',
+ 'C:\Windows\System32\WindowsPowerShell\v1.0\'
+ )
+ }
+
+ $new_path = $new_path -join $sep
+ echo "PATH=$new_path" >> $env:GITHUB_ENV
+ } else {
+ echo "::warning ::Not going to clean up PATH variable on $os"
+ }
+ shell: pwsh
+
+branding:
+ icon: star
+ color: green