Skip to content

Commit 2a6afcb

Browse files
🩹 [Patch]: Improve logging details (#12)
## Description - Improve logging details ## Type of change <!-- Use the check-boxes [x] on the options that are relevant. --> - [ ] 📖 [Docs] - [ ] 🪲 [Fix] - [x] 🩹 [Patch] - [ ] ⚠️ [Security fix] - [ ] 🚀 [Feature] - [ ] 🌟 [Breaking change] ## Checklist <!-- Use the check-boxes [x] on the options that are relevant. --> - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas
1 parent b043904 commit 2a6afcb

File tree

2 files changed

+21
-35
lines changed

2 files changed

+21
-35
lines changed

.github/workflows/Action-Test.yml

Lines changed: 7 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,6 @@ jobs:
4040
uses: ./
4141
with:
4242
Script: |
43-
LogGroup 'Get-GitHubContext' {
44-
Get-GitHubContext
45-
}
46-
47-
LogGroup 'Get-GitHubGitConfig' {
48-
Get-GitHubGitConfig
49-
}
50-
5143
LogGroup 'Get-GitHubZen' {
5244
Get-GitHubZen
5345
}
@@ -65,10 +57,6 @@ jobs:
6557
with:
6658
Token: ''
6759
Script: |
68-
LogGroup 'Get-GitHubContext' {
69-
Get-GitHubContext
70-
}
71-
7260
LogGroup 'My group' {
7361
'This is a group'
7462
}
@@ -86,12 +74,8 @@ jobs:
8674
with:
8775
Token: ${{ secrets.TEST_PAT }}
8876
Script: |
89-
LogGroup 'Get-GitHubContext' {
90-
Get-GitHubContext
91-
}
92-
9377
LogGroup 'Get-GitHubUser' {
94-
Get-GitHubUser
78+
Get-GitHubUser | Format-Table -AutoSize
9579
}
9680
9781
ActionTestWithFGPAT:
@@ -107,12 +91,8 @@ jobs:
10791
with:
10892
Token: ${{ secrets.TEST_FG_PAT }}
10993
Script: |
110-
LogGroup 'Get-GitHubContext' {
111-
Get-GitHubContext
112-
}
113-
11494
LogGroup 'Get-GitHubUser' {
115-
Get-GitHubUser
95+
Get-GitHubUser | Format-Table -AutoSize
11696
}
11797
11898
ActionTestWithGitHubApp:
@@ -129,21 +109,18 @@ jobs:
129109
ClientID: ${{ secrets.TEST_APP_CLIENT_ID }}
130110
PrivateKey: ${{ secrets.TEST_APP_PRIVATE_KEY }}
131111
Script: |
132-
LogGroup 'Get-GitHubContext' {
133-
Get-GitHubContext
134-
}
135-
136112
LogGroup 'Get-GitHubApp' {
137-
Get-GitHubApp
113+
Get-GitHubApp | Format-Table -AutoSize
138114
}
139115
140116
LogGroup 'Get-GitHubAppInstallation' {
141-
Get-GitHubAppInstallation
117+
Get-GitHubAppInstallation | Format-Table -AutoSize
142118
}
143119
144120
LogGroup 'Do something as an installation' {
145121
Get-GithubAppInstallation | New-GitHubAppInstallationAccessToken | ForEach-Object {
146-
Connect-GitHub -Token $_.token
147-
Get-GitHubGitConfig
122+
Connect-GitHub -Token $_.token -Silent
123+
Get-GitHubContext | Format-Table -AutoSize
124+
Get-GitHubGitConfig | Format-Table -AutoSize
148125
}
149126
}

scripts/main.ps1

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,22 +46,31 @@ if (-not $alreadyImported) {
4646
Write-Verbose "Importing module: $Name"
4747
Import-Module -Name $Name
4848
}
49+
50+
Write-Host 'Installed modules:'
51+
Get-InstalledPSResource | Select-Object Name, Version, Prerelease | Format-Table -AutoSize
52+
53+
Write-Host 'GitHub module configuration:'
54+
Get-GitHubConfig | Select-Object Name, ID, RunEnv | Format-Table -AutoSize
55+
4956
'::endgroup::'
5057

5158
$providedToken = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_Token)
5259
$providedClientID = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_ClientID)
5360
$providedPrivateKey = -not [string]::IsNullOrEmpty($env:GITHUB_ACTION_INPUT_PrivateKey)
54-
Write-Verbose "Provided authentication info:"
61+
Write-Verbose 'Provided authentication info:'
5562
Write-Verbose "Token: [$providedToken]"
5663
Write-Verbose "ClientID: [$providedClientID]"
5764
Write-Verbose "PrivateKey: [$providedPrivateKey]"
5865

5966
if ($providedClientID -and $providedPrivateKey) {
60-
LogGroup 'Connect-Github - GitHub App' {
61-
Connect-Github -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey
67+
LogGroup 'Connecting using provided GitHub App' {
68+
Connect-GitHub -ClientID $env:GITHUB_ACTION_INPUT_ClientID -PrivateKey $env:GITHUB_ACTION_INPUT_PrivateKey -Silent
69+
Get-GitHubContext | Format-Table -AutoSize
6270
}
6371
} elseif ($providedToken) {
64-
LogGroup 'Connect-Github - Token' {
65-
Connect-Github -Token $env:GITHUB_ACTION_INPUT_Token
72+
LogGroup 'Connecting using provided token' {
73+
Connect-GitHub -Token $env:GITHUB_ACTION_INPUT_Token -Silent
74+
Get-GitHubContext | Format-Table -AutoSize
6675
}
6776
}

0 commit comments

Comments
 (0)