From e648fd71905aae0a0a76fb78ed7edf0d526686c3 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Fri, 13 Nov 2020 13:18:20 +0300 Subject: do nothing if not on Windows --- action.yml | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) (limited to 'action.yml') diff --git a/action.yml b/action.yml index a418c44..ab49669 100644 --- a/action.yml +++ b/action.yml @@ -85,34 +85,37 @@ runs: } } - $old_values = @{} - Get-ChildItem env: | %{ $old_values.Add($_.Name, $_.Value) } - - $info = Locate-VS - try { - Import-PS $info - } catch { - echo $_ - Import-CMD $info - } - - $new_values = @{} - Get-ChildItem env: | %{ $new_values.Add($_.Name, $_.Value) } + if ('${{ runner.os }}' -ne 'Windows') { + echo 'Not going to set up a Visual Studio shell on ${{ runner.os }}' + } else { + $old_values = @{} + Get-ChildItem env: | %{ $old_values.Add($_.Name, $_.Value) } + + $info = Locate-VS + try { + Import-PS $info + } catch { + echo $_ + Import-CMD $info + } - # Some diagnostics as to which exact variables were modified follows: - echo '----------------------------------------------------------------' - echo 'New variables' - echo '----------------------------------------------------------------' - $new_values.GetEnumerator() | where { -not $old_values.ContainsKey($_.Name) } | Format-List + $new_values = @{} + Get-ChildItem env: | %{ $new_values.Add($_.Name, $_.Value) } - echo '----------------------------------------------------------------' - echo 'Modified variables' - echo '----------------------------------------------------------------' - $new_values.GetEnumerator() | where { $old_values.ContainsKey($_.Name) -and $old_values[$_.Name] -ne $_.Value } | Format-List + # Some diagnostics as to which exact variables were modified follows: + echo '----------------------------------------------------------------' + echo 'New variables' + echo '----------------------------------------------------------------' + $new_values.GetEnumerator() | where { -not $old_values.ContainsKey($_.Name) } | Format-List + echo '----------------------------------------------------------------' + echo 'Modified variables' + echo '----------------------------------------------------------------' + $new_values.GetEnumerator() | where { $old_values.ContainsKey($_.Name) -and $old_values[$_.Name] -ne $_.Value } | Format-List - # Update the current environment: - Get-ChildItem env: | %{ echo "$($_.Name)=$($_.Value)" >> $env:GITHUB_ENV } + # Update the current environment: + Get-ChildItem env: | %{ echo "$($_.Name)=$($_.Value)" >> $env:GITHUB_ENV } + } shell: pwsh branding: icon: star -- cgit v1.2.3