Skip to content

Commit

Permalink
Merge pull request #91 from freddydk/main
Browse files Browse the repository at this point in the history
Fix for #90
  • Loading branch information
freddydk authored Apr 25, 2022
2 parents 380a7c4 + 66a00e5 commit 1459767
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions Actions/ReadSettings/ReadSettings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -133,24 +133,25 @@ try {
}

if ($getenvironments) {
$headers = @{
"Authorization" = "token $token"
"Accept" = "application/vnd.github.v3+json"
}
$url = "$($ENV:GITHUB_API_URL)/repos/$($ENV:GITHUB_REPOSITORY)/environments"
try {
$environments = @($settings.Environments)+@((Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri $url | ConvertFrom-Json).environments | Where-Object {
if ($includeProduction) {
$_.Name -like $getEnvironments -or $_.Name -like "$getEnvironments (Production)"
}
else {
$_.Name -like $getEnvironments -and $_.Name -notlike '* (Production)'
}
} | ForEach-Object { $_.Name })
$environments = @()
try {
$headers = @{
"Authorization" = "token $token"
"Accept" = "application/vnd.github.v3+json"
}
$url = "$($ENV:GITHUB_API_URL)/repos/$($ENV:GITHUB_REPOSITORY)/environments"
$environments = @((Invoke-WebRequest -UseBasicParsing -Headers $headers -Uri $url | ConvertFrom-Json).environments | ForEach-Object { $_.Name })
}
catch {
$environments = @()
}
$environments = @($environments+@($settings.Environments) | Where-Object {
if ($includeProduction) {
$_ -like $getEnvironments -or $_ -like "$getEnvironments (Production)"
}
else {
$_ -like $getEnvironments -and $_ -notlike '* (Production)'
}
})
if ($environments.Count -eq 1) {
$environmentsJSon = "[$($environments | ConvertTo-Json -compress)]"
}
Expand Down

0 comments on commit 1459767

Please sign in to comment.