Skip to content

Commit b416b33

Browse files
committed
20220617B
1 parent bedebed commit b416b33

11 files changed

+41
-38
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Import-Module -Name 'hugoalh.GitHubActionsToolkit' -Prefix 'GitHubActions' -Scop
5656
- `Exit-GitHubActionsLogGroup`
5757
- `Get-GitHubActionsInput`
5858
- `Get-GitHubActionsIsDebug`
59-
- `Get-GitHubActionsOidcToken` 🧪
59+
- `Get-GitHubActionsOpenIdConnectToken` 🧪
6060
- `Get-GitHubActionsState`
6161
- `Get-GitHubActionsStepSummary`
6262
- `Get-GitHubActionsWebhookEventPayload`

hugoalh.GitHubActionsToolkit/_get-package-commands.ps1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
This script is use for debug, and help to copy commands to hugoalh.GitHubActionsToolkit.psd1 file (for best performance).
55
#>
66
Import-Module -Name (Join-Path -Path $PSScriptRoot -ChildPath 'hugoalh.GitHubActionsToolkit.psm1') -Scope 'Local'
7-
[PSCustomObject[]]$ModulesCommands = Get-Command -Module 'hugoalh.GitHubActionsToolkit' -ListImported
8-
foreach ($Type in @('Function', 'Alias')) {
9-
Set-Clipboard -Value "'$(($ModulesCommands | Where-Object -FilterScript {
10-
return ($_.CommandType -ieq $Type)
7+
[PSCustomObject[]]$PackageCommands = Get-Command -Module 'hugoalh.GitHubActionsToolkit' -ListImported
8+
foreach ($CommandType in @('Function', 'Alias')) {
9+
Set-Clipboard -Value "'$(($PackageCommands | Where-Object -FilterScript {
10+
return ($_.CommandType -ieq $CommandType)
1111
} | Sort-Object -Property 'Name').Name -join "',`n'")'" -Confirm
1212
}

hugoalh.GitHubActionsToolkit/hugoalh.GitHubActionsToolkit.psd1

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
'Exit-LogGroup',
7474
'Get-Input',
7575
'Get-IsDebug',
76-
'Get-OidcToken',
76+
'Get-OpenIdConnectToken',
7777
'Get-State',
7878
'Get-StepSummary',
7979
'Get-WebhookEventPayload',
@@ -134,6 +134,7 @@
134134
'Enter-Group',
135135
'Exit-Group',
136136
'Get-Event',
137+
'Get-OidcToken',
137138
'Get-Payload',
138139
'Get-WebhookEvent',
139140
'Get-WebhookPayload',
Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
11
#Requires -PSEdition Core
22
#Requires -Version 7.2
33
[String]$ModuleRoot = Join-Path -Path $PSScriptRoot -ChildPath 'module'
4-
[String[]]$ModulesName = @(
4+
[String[]]$ModulesNames = @(
55
'command-base',
66
'command-control',
77
'environment-variable',
88
'log',
9-
'oidc',
9+
'open-id-connect',
1010
'parameter',
1111
'problem-matcher',
1212
'step-summary',
1313
'utility'
1414
)
15-
[String[]]$ModulesFullName = $ModulesName | ForEach-Object -Process {
15+
Import-Module -Name ($ModulesNames | ForEach-Object -Process {
1616
return Join-Path -Path $ModuleRoot -ChildPath "$_.psm1"
17-
}
18-
Import-Module -Name $ModulesFullName -Scope 'Local'
19-
[PSCustomObject[]]$ModulesCommands = Get-Command -Module $ModulesName -ListImported
20-
[String[]]$ModulesCommandsFunctions = ($ModulesCommands | Where-Object -FilterScript {
17+
}) -Scope 'Local'
18+
[PSCustomObject[]]$PackageCommands = Get-Command -Module $ModulesNames -ListImported
19+
[String[]]$PackageCommandsFunctions = ($PackageCommands | Where-Object -FilterScript {
2120
return ($_.CommandType -ieq 'Function')
2221
}).Name
23-
[String[]]$ModulesCommandsAliases = ($ModulesCommands | Where-Object -FilterScript {
22+
[String[]]$PackageCommandsAliases = ($PackageCommands | Where-Object -FilterScript {
2423
return ($_.CommandType -ieq 'Alias')
2524
}).Name
26-
Export-ModuleMember -Function $ModulesCommandsFunctions -Alias $ModulesCommandsAliases
25+
Export-ModuleMember -Function $PackageCommandsFunctions -Alias $PackageCommandsAliases

hugoalh.GitHubActionsToolkit/module/command-base.psm1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function Write-Command {
6363
)
6464
begin {}
6565
process {
66-
Write-Host -Object "::$Command$(($Parameter.Count -gt 0) ? " $(($Parameter.GetEnumerator() | Sort-Object -Property 'Name' | ForEach-Object -Process {
66+
Write-Host -Object "::$Command$(($Parameter.Count -igt 0) ? " $(($Parameter.GetEnumerator() | Sort-Object -Property 'Name' | ForEach-Object -Process {
6767
return "$($_.Name)=$(Format-CommandParameter -InputObject $_.Value)"
6868
}) -join ',')" : '')::$(Format-CommandValue -InputObject $Value)"
6969
}

hugoalh.GitHubActionsToolkit/module/command-control.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ function Disable-ProcessingCommands {
6363
[OutputType([String])]
6464
param (
6565
[Parameter(Position = 0)][ValidateScript({
66-
return ($_ -imatch '^.+$' -and $_.Length -ge 4 -and $_ -inotin $GitHubActionsCommands)
66+
return ($_ -imatch '^.+$' -and $_.Length -ige 4 -and $_ -inotin $GitHubActionsCommands)
6767
}, ErrorMessage = 'Parameter `EndToken` must be in single line string, more than or equal to 4 characters, not match any GitHub Actions commands, and unique!')][Alias('EndKey', 'EndValue', 'Key', 'Token', 'Value')][String]$EndToken = ((New-Guid).Guid -ireplace '-', '')
6868
)
6969
Write-GitHubActionsCommand -Command 'stop-commands' -Value $EndToken
@@ -128,7 +128,7 @@ function Enable-ProcessingCommands {
128128
[OutputType([Void])]
129129
param (
130130
[Parameter(Mandatory = $true, Position = 0)][ValidateScript({
131-
return ($_ -imatch '^.+$' -and $_.Length -ge 4 -and $_ -inotin $GitHubActionsCommands)
131+
return ($_ -imatch '^.+$' -and $_.Length -ige 4 -and $_ -inotin $GitHubActionsCommands)
132132
}, ErrorMessage = 'Parameter `EndToken` must be in single line string, more than or equal to 4 characters, and not match any GitHub Actions commands!')][Alias('EndKey', 'EndValue', 'Key', 'Token', 'Value')][String]$EndToken
133133
)
134134
return Write-GitHubActionsCommand -Command $EndToken

hugoalh.GitHubActionsToolkit/module/environment-variable.psm1

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function Add-PATH {
3030
[String[]]$Result = @()
3131
}
3232
process {
33-
foreach ($Item in ($Path | Select-Object -Unique)) {
33+
foreach ($Item in $Path) {
3434
if (!$NoValidator -and !(Test-Path -Path $Item -PathType 'Container' -IsValid)) {
3535
Write-Error -Message "``$Item`` is not a valid PATH!" -Category 'SyntaxError'
3636
continue
@@ -39,7 +39,7 @@ function Add-PATH {
3939
}
4040
}
4141
end {
42-
if ($Result.Count -gt 0) {
42+
if ($Result.Count -igt 0) {
4343
switch ($Scope -isplit ', ') {
4444
{ $_ -icontains 'Current' } {
4545
[String[]]$PATHRaw = [System.Environment]::GetEnvironmentVariable('PATH') -isplit [System.IO.Path]::PathSeparator
@@ -120,7 +120,7 @@ function Set-EnvironmentVariable {
120120
}
121121
}
122122
end {
123-
if ($Result.Count -gt 0) {
123+
if ($Result.Count -igt 0) {
124124
[PSCustomObject[]]$ResultEnumerator = $Result.GetEnumerator()
125125
switch ($Scope -isplit ', ') {
126126
{ $_ -icontains 'Current' } {

hugoalh.GitHubActionsToolkit/module/log.psm1

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,22 @@ function Write-Annotation {
102102
}
103103
}
104104
[Hashtable]$Property = @{}
105-
if ($File.Length -gt 0) {
105+
if ($File.Length -igt 0) {
106106
$Property.'file' = $File
107107
}
108-
if ($Line -gt 0) {
108+
if ($Line -igt 0) {
109109
$Property.'line' = $Line
110110
}
111-
if ($Column -gt 0) {
111+
if ($Column -igt 0) {
112112
$Property.'col' = $Column
113113
}
114-
if ($EndLine -gt 0) {
114+
if ($EndLine -igt 0) {
115115
$Property.'endLine' = $EndLine
116116
}
117-
if ($EndColumn -gt 0) {
117+
if ($EndColumn -igt 0) {
118118
$Property.'endColumn' = $EndColumn
119119
}
120-
if ($Title.Length -gt 0) {
120+
if ($Title.Length -igt 0) {
121121
$Property.'title' = $Title
122122
}
123123
Write-GitHubActionsCommand -Command $TypeRaw -Value $Message -Parameter $Property

hugoalh.GitHubActionsToolkit/module/oidc.psm1 renamed to hugoalh.GitHubActionsToolkit/module/open-id-connect.psm1

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ Import-Module -Name @(
55
) -Prefix 'GitHubActions' -Scope 'Local'
66
<#
77
.SYNOPSIS
8-
GitHub Actions - Get OIDC Token
8+
GitHub Actions - Get OpenID Connect Token
99
.DESCRIPTION
10-
Interact with the GitHub OIDC provider and get a JWT ID token which would help to get access token from third party cloud providers.
10+
Interact with the GitHub OpenID Connect (OIDC) provider and get a JSON Web Token (JWT) ID token which would help to get access token from third party cloud providers.
1111
.PARAMETER Audience
1212
Audience.
1313
.OUTPUTS
1414
String
1515
#>
16-
function Get-OidcToken {
17-
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_get-githubactionsoidctoken#Get-GitHubActionsOidcToken')]
16+
function Get-OpenIdConnectToken {
17+
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_get-githubactionsopenidconnecttoken#Get-GitHubActionsOpenIdConnectToken')]
1818
[OutputType([String])]
1919
param (
2020
[Parameter(Position = 0)][String]$Audience
@@ -28,7 +28,7 @@ function Get-OidcToken {
2828
if ($OidcTokenRequestURL.Length -ieq 0) {
2929
return Write-Error -Message 'Unable to get GitHub Actions OIDC token request URL!' -Category 'ResourceUnavailable'
3030
}
31-
if ($Audience.Length -gt 0) {
31+
if ($Audience.Length -igt 0) {
3232
Add-GitHubActionsSecretMask -Value $Audience
3333
[String]$AudienceEncode = [System.Web.HttpUtility]::UrlEncode($Audience)
3434
Add-GitHubActionsSecretMask -Value $AudienceEncode
@@ -45,6 +45,9 @@ function Get-OidcToken {
4545
return Write-Error @_
4646
}
4747
}
48+
Set-Alias -Name 'Get-OidcToken' -Value 'Get-OpenIdConnectToken' -Option 'ReadOnly' -Scope 'Local'
4849
Export-ModuleMember -Function @(
50+
'Get-OpenIdConnectToken'
51+
) -Alias @(
4952
'Get-OidcToken'
5053
)

hugoalh.GitHubActionsToolkit/module/step-summary.psm1

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,12 @@ function Add-StepSummary {
2323
[String[]]$Result = @()
2424
}
2525
process {
26-
if ($Value.Count -gt 0) {
26+
if ($Value.Count -igt 0) {
2727
$Result += $Value -join "`n"
2828
}
2929
}
3030
end {
31-
if ($Result.Count -gt 0) {
31+
if ($Result.Count -igt 0) {
3232
Add-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Value ($Result -join "`n") -Confirm:$false -NoNewline:$NoNewLine -Encoding 'UTF8NoBOM'
3333
}
3434
return
@@ -100,12 +100,12 @@ function Set-StepSummary {
100100
[String[]]$Result = @()
101101
}
102102
process {
103-
if ($Value.Count -gt 0) {
103+
if ($Value.Count -igt 0) {
104104
$Result += $Value -join "`n"
105105
}
106106
}
107107
end {
108-
if ($Result.Count -gt 0) {
108+
if ($Result.Count -igt 0) {
109109
Set-Content -LiteralPath $env:GITHUB_STEP_SUMMARY -Value ($Result -join "`n") -Confirm:$false -NoNewline:$NoNewLine -Encoding 'UTF8NoBOM'
110110
}
111111
return

0 commit comments

Comments
 (0)