Skip to content

Commit 8bcae22

Browse files
committed
20220630D
1 parent 9c8eb10 commit 8bcae22

File tree

7 files changed

+21
-44
lines changed

7 files changed

+21
-44
lines changed

hugoalh.GitHubActionsToolkit/module/artifact.psm1

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ Absolute and/or relative path to the file that need to export as artifact.
1717
Absolute and/or relative literal path to the file that need to export as artifact.
1818
.PARAMETER BaseRoot
1919
A (literal) path that denote the base root directory of the files for control files structure.
20-
.PARAMETER IgnoreIssuePaths
21-
Whether the export should continue in the event of files fail to export; If set to `$False` and issue is encountered, export will stop and queued files will not export; The partial artifact availables which include files up until the issue; If set to `$True` and issue is encountered, the issue file will ignore and skip, and queued files will still export; The partial artifact availables which include everything but exclude issue files.
20+
.PARAMETER ContinueOnIssue
21+
Whether the export should continue in the event of files fail to export; If not set and issue is encountered, export will stop and queued files will not export; The partial artifact availables which include files up until the issue; If set and issue is encountered, the issue file will ignore and skip, and queued files will still export; The partial artifact availables which include everything but exclude issue files.
2222
.PARAMETER RetentionTime
2323
Duration of artifact expire by days.
2424
.OUTPUTS
@@ -28,15 +28,11 @@ Function Export-Artifact {
2828
[CmdletBinding(DefaultParameterSetName = 'Path', HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_export-githubactionsartifact#Export-GitHubActionsArtifact')]
2929
[OutputType([PSCustomObject])]
3030
Param (
31-
[Parameter(Mandatory = $True, Position = 0)][ValidateScript({
32-
Return (Test-ArtifactName -InputObject $_)
33-
}, ErrorMessage = '`{0}` is not a valid GitHub Actions artifact name!')][String]$Name,
31+
[Parameter(Mandatory = $True, Position = 0)][ValidateScript({ Return (Test-ArtifactName -InputObject $_) }, ErrorMessage = '`{0}` is not a valid GitHub Actions artifact name!')][String]$Name,
3432
[Parameter(Mandatory = $True, ParameterSetName = 'Path', Position = 1, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][SupportsWildcards()][Alias('File', 'Files', 'Paths')][String[]]$Path,
3533
[Parameter(Mandatory = $True, ParameterSetName = 'LiteralPath', ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][Alias('LiteralFile', 'LiteralFiles', 'LiteralPaths', 'LP', 'PSPath', 'PSPaths')][String[]]$LiteralPath,
36-
[ValidateScript({
37-
Return ([System.IO.Path]::IsPathRooted($_) -and (Test-Path -LiteralPath $_ -PathType 'Container'))
38-
}, ErrorMessage = '`{0}` is not an exist and valid GitHub Actions artifact base root!')][Alias('Root')][String]$BaseRoot = $Env:GITHUB_WORKSPACE,
39-
[Alias('ContinueOnError', 'ContinueOnIssue', 'IgnoreIssuePath')][Switch]$IgnoreIssuePaths,
34+
[ValidateScript({ Return ([System.IO.Path]::IsPathRooted($_) -and (Test-Path -LiteralPath $_ -PathType 'Container')) }, ErrorMessage = '`{0}` is not an exist and valid GitHub Actions artifact base root!')][Alias('Root')][String]$BaseRoot = $Env:GITHUB_WORKSPACE,
35+
[Alias('ContinueOnError')][Switch]$ContinueOnIssue,
4036
[ValidateRange(1, 90)][Alias('RetentionDay')][Byte]$RetentionTime = 0
4137
)
4238
Begin {
@@ -75,7 +71,7 @@ Function Export-Artifact {
7571
Return ($_ -ireplace $BaseRootRegularExpression, '' -ireplace '\\', '/')
7672
})
7773
BaseRoot = $BaseRoot
78-
IgnoreIssuePaths = $IgnoreIssuePaths.IsPresent
74+
ContinueOnIssue = $ContinueOnIssue.IsPresent
7975
}
8076
If ($RetentionTime -igt 0) {
8177
$InputObject.RetentionTIme = $RetentionTime
@@ -95,25 +91,23 @@ GitHub Actions - Import Artifact
9591
Import artifact that shared data from previous job in the same workflow.
9692
.PARAMETER Name
9793
Artifact name.
98-
.PARAMETER Destination
99-
Artifact destination.
10094
.PARAMETER CreateSubfolder
101-
Create a subfolder with artifact name and put data into here.
95+
Create a subfolder with artifact name and put data into here; When parameter `Name` has multiple values, this parameter will ignore.
10296
.PARAMETER All
103-
Import all artifacts that shared data from previous job in the same workflow.
97+
Import all artifacts that shared data from previous job in the same workflow; Always create subfolder.
98+
.PARAMETER Destination
99+
Artifact destination.
104100
.OUTPUTS
105101
[PSCustomObject[]] Imported artifacts' metadata.
106102
#>
107103
Function Import-Artifact {
108104
[CmdletBinding(DefaultParameterSetName = 'Select', HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_import-githubactionsartifact#Import-GitHubActionsArtifact')]
109105
[OutputType([PSCustomObject[]])]
110106
Param (
111-
[Parameter(Mandatory = $True, ParameterSetName = 'Select', Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][ValidateScript({
112-
Return (Test-ArtifactName -InputObject $_)
113-
}, ErrorMessage = '`{0}` is not a valid GitHub Actions artifact name!')][String[]]$Name,
107+
[Parameter(Mandatory = $True, ParameterSetName = 'Select', Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][ValidateScript({ Return (Test-ArtifactName -InputObject $_) }, ErrorMessage = '`{0}` is not a valid GitHub Actions artifact name!')][String[]]$Name,
114108
[Parameter(ParameterSetName = 'Select')][Switch]$CreateSubfolder,
115109
[Parameter(Mandatory = $True, ParameterSetName = 'All')][Switch]$All,
116-
[String]$Destination = $Env:GITHUB_WORKSPACE
110+
[Alias('Dest', 'Target')][String]$Destination = $Env:GITHUB_WORKSPACE
117111
)
118112
Begin {
119113
If (!(Test-GitHubActionsEnvironment -Artifact)) {
@@ -138,7 +132,7 @@ Function Import-Artifact {
138132
$ResultRaw = Invoke-GitHubActionsNodeJsWrapper -Path 'artifact\download.js' -InputObject ([PSCustomObject]@{
139133
Name = $Item
140134
Destination = $Destination
141-
CreateSubfolder = $CreateSubfolder.IsPresent
135+
CreateSubfolder = ($Name.Count -igt 1) ? $True : $CreateSubfolder.IsPresent
142136
} | ConvertTo-Json -Depth 100 -Compress)
143137
If ($ResultRaw -ieq $False) {
144138
Continue

hugoalh.GitHubActionsToolkit/module/cache.psm1

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ Function Restore-Cache {
2828
[CmdletBinding(DefaultParameterSetName = 'Path', HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_restore-githubactionscache#Restore-GitHubActionsCache')]
2929
[OutputType([String])]
3030
Param (
31-
[Parameter(Mandatory = $True, Position = 0)][ValidateScript({
32-
Return (Test-CacheKey -InputObject $_)
33-
}, ErrorMessage = '`{0}` is not a valid GitHub Actions cache key, and/or more than 512 characters!')][Alias('Keys', 'Name', 'Names')][String[]]$Key,
31+
[Parameter(Mandatory = $True, Position = 0)][ValidateScript({ Return (Test-CacheKey -InputObject $_) }, ErrorMessage = '`{0}` is not a valid GitHub Actions cache key, and/or more than 512 characters!')][Alias('Keys', 'Name', 'Names')][String[]]$Key,
3432
[Parameter(Mandatory = $True, ParameterSetName = 'Path', Position = 1, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][SupportsWildcards()][Alias('File', 'Files', 'Paths')][String[]]$Path,
3533
[Parameter(Mandatory = $True, ParameterSetName = 'LiteralPath', ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][Alias('LiteralFile', 'LiteralFiles', 'LiteralPaths', 'LP', 'PSPath', 'PSPaths')][String[]]$LiteralPath,
3634
[Alias('NoAzureSdk')][Switch]$NotUseAzureSdk,
@@ -111,9 +109,7 @@ Function Save-Cache {
111109
[CmdletBinding(DefaultParameterSetName = 'Path', HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_save-githubactionscache#Save-GitHubActionsCache')]
112110
[OutputType([String])]
113111
Param (
114-
[Parameter(Mandatory = $True, Position = 0)][ValidateScript({
115-
Return (Test-CacheKey -InputObject $_)
116-
}, ErrorMessage = '`{0}` is not a valid GitHub Actions cache key, and/or more than 512 characters!')][Alias('Name')][String]$Key,
112+
[Parameter(Mandatory = $True, Position = 0)][ValidateScript({ Return (Test-CacheKey -InputObject $_) }, ErrorMessage = '`{0}` is not a valid GitHub Actions cache key, and/or more than 512 characters!')][Alias('Name')][String]$Key,
117113
[Parameter(Mandatory = $True, ParameterSetName = 'Path', Position = 1, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][SupportsWildcards()][Alias('File', 'Files', 'Paths')][String[]]$Path,
118114
[Parameter(Mandatory = $True, ParameterSetName = 'LiteralPath', ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][Alias('LiteralFile', 'LiteralFiles', 'LiteralPaths', 'LP', 'PSPath', 'PSPaths')][String[]]$LiteralPath,
119115
[ValidateRange(1KB, 1GB)][UInt32]$UploadChunkSizes = 0,

hugoalh.GitHubActionsToolkit/module/command-control.psm1

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,7 @@ Function Disable-ProcessingCommands {
6363
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_disable-githubactionsprocessingcommands#Disable-GitHubActionsProcessingCommands')]
6464
[OutputType([String])]
6565
Param (
66-
[Parameter(Position = 0)][ValidateScript({
67-
Return (Test-ProcessingCommandsEndToken -InputObject $_)
68-
}, 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 '-', '')
66+
[Parameter(Position = 0)][ValidateScript({ Return (Test-ProcessingCommandsEndToken -InputObject $_) }, 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 '-', '')
6967
)
7068
Write-GitHubActionsCommand -Command 'stop-commands' -Value $EndToken
7169
Return $EndToken
@@ -128,9 +126,7 @@ Function Enable-ProcessingCommands {
128126
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_enable-githubactionsprocessingcommands#Enable-GitHubActionsProcessingCommands')]
129127
[OutputType([Void])]
130128
Param (
131-
[Parameter(Mandatory = $True, Position = 0)][ValidateScript({
132-
Return (Test-ProcessingCommandsEndToken -InputObject $_)
133-
}, 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
129+
[Parameter(Mandatory = $True, Position = 0)][ValidateScript({ Return (Test-ProcessingCommandsEndToken -InputObject $_) }, 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
134130
)
135131
Return (Write-GitHubActionsCommand -Command $EndToken)
136132
}

hugoalh.GitHubActionsToolkit/module/environment-variable.psm1

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,7 @@ Function Set-EnvironmentVariable {
8686
[OutputType([Void])]
8787
Param (
8888
[Parameter(Mandatory = $True, ParameterSetName = 'Multiple', Position = 0, ValueFromPipeline = $True)][Alias('Input', 'Object')][Hashtable]$InputObject,
89-
[Parameter(Mandatory = $True, ParameterSetName = 'Single', Position = 0, ValueFromPipelineByPropertyName = $True)][ValidateScript({
90-
Return (Test-EnvironmentVariableName -InputObject $_)
91-
}, ErrorMessage = '`{0}` is not a valid environment variable name!')][Alias('Key')][String]$Name,
89+
[Parameter(Mandatory = $True, ParameterSetName = 'Single', Position = 0, ValueFromPipelineByPropertyName = $True)][ValidateScript({ Return (Test-EnvironmentVariableName -InputObject $_) }, ErrorMessage = '`{0}` is not a valid environment variable name!')][Alias('Key')][String]$Name,
9290
[Parameter(Mandatory = $True, ParameterSetName = 'Single', Position = 1, ValueFromPipelineByPropertyName = $True)][ValidatePattern('^.+$', ErrorMessage = 'Parameter `Value` must be in single line string!')][String]$Value,
9391
[Alias('NoToUppercase')][Switch]$NoToUpper,
9492
[GitHubActionsEnvironmentVariableScopes]$Scope = [GitHubActionsEnvironmentVariableScopes]3

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper/artifact/upload.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
import { create as ghactionsArtifact } from "@actions/artifact";
33
const input = JSON.parse(process.argv[2]);
44
const result = await ghactionsArtifact().uploadArtifact(input.Name, input.Path, input.BaseRoot, {
5-
continueOnError: input.IgnoreIssuePaths,
5+
continueOnError: input.ContinueOnIssue,
66
retentionDays: input.RetentionTime
77
}).catch((reason) => {
88
console.error(reason);

hugoalh.GitHubActionsToolkit/module/nodejs-wrapper/cache/restore.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ const result = await ghactionsCacheRestoreCache(input.Path, input.PrimaryKey, in
1111
});
1212
console.log(process.argv[3]);
1313
console.log(JSON.stringify({
14-
CacheKey: result ?? null
14+
CacheKey: result
1515
}));
1616
process.exit(0);

hugoalh.GitHubActionsToolkit/module/tool-cache.psm1

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -150,14 +150,7 @@ Function Invoke-ToolCacheToolDownloader {
150150
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_invoke-githubactionstoolcachetooldownloader#Invoke-GitHubActionsToolCacheToolDownloader')]
151151
[OutputType([String[]])]
152152
Param (
153-
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][ValidateScript({
154-
Try {
155-
$UriObject = $_ -as [System.Uri]
156-
} Catch {
157-
Return $False
158-
}
159-
Return (($Null -ine $UriObject.AbsoluteUri) -and ($_.Scheme -imatch '^https?$'))
160-
}, ErrorMessage = '`{0}` is not a valid URI!')][Alias('Url')][String[]]$Uri,
153+
[Parameter(Mandatory = $True, Position = 0, ValueFromPipeline = $True, ValueFromPipelineByPropertyName = $True)][ValidateScript({ Return (($Null -ine $_.AbsoluteUri) -and ($_.Scheme -imatch '^https?$')) }, ErrorMessage = '`{0}` is not a valid URI!')][Alias('Url')][Uri]$Uri,
161154
[Alias('Target')][String]$Destination,
162155
[Alias('Auth')][String]$Authorization,
163156
[Alias('Headers')][Hashtable]$Header

0 commit comments

Comments
 (0)