-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathAfterAll.ps1
More file actions
47 lines (38 loc) · 1.52 KB
/
AfterAll.ps1
File metadata and controls
47 lines (38 loc) · 1.52 KB
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
[CmdletBinding()]
param()
LogGroup 'AfterAll - Global Test Teardown' {
$authCases = . "$PSScriptRoot/Data/AuthCases.ps1"
$prefix = 'Test'
$os = $env:RUNNER_OS
$id = $env:GITHUB_RUN_ID
foreach ($authCase in $authCases) {
$authCase.GetEnumerator() | ForEach-Object { Set-Variable -Name $_.Key -Value $_.Value }
if ($TokenType -eq 'GITHUB_TOKEN') {
Write-Host "Skipping setup for $AuthType-$TokenType (uses existing repository)"
continue
}
LogGroup "Repository setup - $AuthType-$TokenType" {
$context = Connect-GitHubAccount @connectParams -PassThru -Silent
if ($AuthType -eq 'APP') {
$context = Connect-GitHubApp @connectAppParams -PassThru -Default -Silent
}
Write-Host ($context | Format-List | Out-String)
$repoPrefix = "$prefix-$os-$TokenType"
switch ($OwnerType) {
'user' {
Get-GitHubRepository | Where-Object { $_.Name -like "$repoPrefix*" } | Remove-GitHubRepository -Confirm:$false
}
'organization' {
Get-GitHubRepository -Organization $Owner | Where-Object { $_.Name -like "$repoPrefix*" } | Remove-GitHubRepository -Confirm:$false
}
}
}
LogGroup 'Environment setup' {
$environmentName = "$prefix-$os-$TokenType-$id"
}
LogGroup 'Variables setup' {
}
LogGroup 'Secrets setup' {
}
}
}