-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathclean.ps1
More file actions
30 lines (26 loc) · 1.19 KB
/
clean.ps1
File metadata and controls
30 lines (26 loc) · 1.19 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
Write-Debug "Cleaning up..."
Write-Debug "LASTEXITCODE: $LASTEXITCODE"
Write-Debug "PSMODULE_GITHUB_SCRIPT: $env:PSMODULE_GITHUB_SCRIPT"
# Check if credentials should be preserved
$preserveCredentials = $env:PSMODULE_GITHUB_SCRIPT_INPUT_PreserveCredentials -eq 'true'
Write-Debug "PreserveCredentials: $preserveCredentials"
if (-not $preserveCredentials) {
Write-Debug "Disconnecting GitHub contexts and CLI..."
try {
# Import GitHub module if not already imported
if (-not (Get-Module -Name GitHub -ErrorAction SilentlyContinue)) {
Import-Module -Name GitHub -ErrorAction SilentlyContinue
}
# Disconnect GitHub account if the module and function are available
if (Get-Command Disconnect-GitHubAccount -ErrorAction SilentlyContinue) {
Disconnect-GitHubAccount
Write-Debug "Successfully disconnected GitHub account"
} else {
Write-Debug "Disconnect-GitHubAccount command not available"
}
} catch {
Write-Warning "Failed to disconnect GitHub account: $($_.Exception.Message)"
}
}
$env:PSMODULE_GITHUB_SCRIPT = $false
Write-Debug "PSMODULE_GITHUB_SCRIPT: $env:PSMODULE_GITHUB_SCRIPT"