|
103 | 103 | $Context = Resolve-GitHubContext -Context $Context |
104 | 104 | Assert-GitHubContext -Context $Context -AuthType App |
105 | 105 | $selectedInstallations = @() |
| 106 | + $moduleVersion = $script:PSModuleInfo.ModuleVersion |
106 | 107 | } |
107 | 108 |
|
108 | 109 | process { |
|
132 | 133 |
|
133 | 134 | switch ($Installation.Type) { |
134 | 135 | 'User' { |
135 | | - $contextParams['InstallationName'] = [string]$installation.Target.Name |
136 | | - $contextParams['Owner'] = [string]$installation.Target.Name |
| 136 | + $contextParams['InstallationName'] = [string]$Installation.Target.Name |
| 137 | + $contextParams['Owner'] = [string]$Installation.Target.Name |
137 | 138 | } |
138 | 139 | 'Organization' { |
139 | | - $contextParams['InstallationName'] = [string]$installation.Target.Name |
140 | | - $contextParams['Owner'] = [string]$installation.Target.Name |
| 140 | + $contextParams['InstallationName'] = [string]$Installation.Target.Name |
| 141 | + $contextParams['Owner'] = [string]$Installation.Target.Name |
141 | 142 | } |
142 | 143 | 'Enterprise' { |
143 | | - $contextParams['InstallationName'] = [string]$installation.Target.Name |
144 | | - $contextParams['Enterprise'] = [string]$installation.Target.Name |
| 144 | + $contextParams['InstallationName'] = [string]$Installation.Target.Name |
| 145 | + $contextParams['Enterprise'] = [string]$Installation.Target.Name |
145 | 146 | } |
146 | 147 | } |
147 | 148 | Write-Verbose 'Logging in using a managed installation access token...' |
148 | 149 | $contextParams | Format-Table | Out-String -Stream | ForEach-Object { Write-Verbose $_ } |
149 | 150 | while ($true) { |
150 | 151 | try { |
151 | 152 | $contextObj = [GitHubAppInstallationContext]::new((Set-GitHubContext -Context $contextParams.Clone() -PassThru -Default:$Default)) |
| 153 | + break |
152 | 154 | } catch { |
153 | 155 | if ($attempts -lt 3) { |
154 | 156 | $attempts++ |
|
178 | 180 | return |
179 | 181 | } |
180 | 182 |
|
181 | | - $Installation | ForEach-Object -ThrottleLimit $ThrottleLimit -UseNewRunspace -Parallel { |
182 | | - Write-Host "Using GitHub $($script:PSModuleInfo.ModuleVersion)" |
183 | | - Import-Module -Name 'GitHub' -RequiredVersion $script:PSModuleInfo.ModuleVersion |
| 183 | + $Installation | ForEach-Object - -ThrottleLimit $ThrottleLimit -UseNewRunspace -Parallel { |
| 184 | + Write-Host "Using GitHub $using:moduleVersion" |
| 185 | + Import-Module -Name 'GitHub' -RequiredVersion $using:moduleVersion |
184 | 186 | $params = @{ |
185 | 187 | Installation = $_ |
186 | 188 | Context = $using:Context |
|
218 | 220 | } |
219 | 221 | } |
220 | 222 | $selectedInstallations | ForEach-Object -ThrottleLimit $ThrottleLimit -UseNewRunspace -Parallel { |
221 | | - Import-Module -Name 'GitHub' -RequiredVersion $script:PSModuleInfo.ModuleVersion -Force |
| 223 | + Write-Host "Using GitHub $using:moduleVersion" |
| 224 | + Import-Module -Name 'GitHub' -RequiredVersion $using:moduleVersion |
222 | 225 | $params = @{ |
223 | 226 | Installation = $_ |
224 | 227 | Context = $using:Context |
|
234 | 237 | Write-Verbose 'No target specified. Connecting to all installations.' |
235 | 238 | $selectedInstallations = Get-GitHubAppInstallation -Context $Context |
236 | 239 | $selectedInstallations | ForEach-Object -ThrottleLimit $ThrottleLimit -UseNewRunspace -Parallel { |
237 | | - Import-Module -Name 'GitHub' -RequiredVersion $script:PSModuleInfo.ModuleVersion -Force |
| 240 | + Write-Host "Using GitHub $using:moduleVersion" |
| 241 | + Import-Module -Name 'GitHub' -RequiredVersion $using:moduleVersion |
238 | 242 | $params = @{ |
239 | 243 | Installation = $_ |
240 | 244 | Context = $using:Context |
|
0 commit comments