@@ -67,9 +67,7 @@ Function Export-Artifact {
67
67
}
68
68
[Hashtable ]$InputObject = @ {
69
69
Name = $Name
70
- Path = ($PathsProceed | ForEach-Object - Process {
71
- Return ($_ -ireplace $BaseRootRegularExpression , ' ' -ireplace ' \\' , ' /' )
72
- })
70
+ Path = $PathsProceed
73
71
BaseRoot = $BaseRoot
74
72
ContinueOnIssue = $ContinueOnIssue.IsPresent
75
73
}
@@ -92,20 +90,22 @@ Import artifact that shared data from previous job in the same workflow.
92
90
. PARAMETER Name
93
91
Artifact name.
94
92
. PARAMETER CreateSubfolder
95
- Create a subfolder with artifact name and put data into here; When parameter `Name` has multiple values, this parameter will ignore .
93
+ Create a subfolder with artifact name and put data into here.
96
94
. PARAMETER All
97
95
Import all artifacts that shared data from previous job in the same workflow; Always create subfolder.
98
96
. PARAMETER Destination
99
97
Artifact destination.
100
98
. OUTPUTS
99
+ [PSCustomObject] Imported artifact's metadata.
101
100
[PSCustomObject[]] Imported artifacts' metadata.
102
101
#>
103
102
Function Import-Artifact {
104
- [CmdletBinding (DefaultParameterSetName = ' Select' , HelpUri = ' https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_import-githubactionsartifact#Import-GitHubActionsArtifact' )]
105
- [OutputType ([PSCustomObject []])]
103
+ [CmdletBinding (DefaultParameterSetName = ' Single' , HelpUri = ' https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_import-githubactionsartifact#Import-GitHubActionsArtifact' )]
104
+ [OutputType ([PSCustomObject []], ParameterSetName = ' All' )]
105
+ [OutputType ([PSCustomObject ], ParameterSetName = ' Single' )]
106
106
Param (
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 ,
108
- [Parameter (ParameterSetName = ' Select ' )][Switch ]$CreateSubfolder ,
107
+ [Parameter (Mandatory = $True , ParameterSetName = ' Single ' , Position = 0 , ValueFromPipeline = $True , ValueFromPipelineByPropertyName = $True )][ValidateScript ({ Return (Test-ArtifactName - InputObject $_ ) }, ErrorMessage = ' `{0}` is not a valid GitHub Actions artifact name!' )][String ]$Name ,
108
+ [Parameter (ParameterSetName = ' Single ' )][Switch ]$CreateSubfolder ,
109
109
[Parameter (Mandatory = $True , ParameterSetName = ' All' )][Switch ]$All ,
110
110
[Alias (' Dest' , ' Target' )][String ]$Destination = $Env: GITHUB_WORKSPACE
111
111
)
@@ -114,7 +114,6 @@ Function Import-Artifact {
114
114
Return (Write-Error - Message ' Unable to get GitHub Actions artifact resources!' - Category ' ResourceUnavailable' )
115
115
Break # This is the best way to early terminate this function without terminate caller/invoker process.
116
116
}
117
- [PSCustomObject []]$OutputObject = @ ()
118
117
}
119
118
Process {
120
119
Switch ($PSCmdlet.ParameterSetName ) {
@@ -125,26 +124,22 @@ Function Import-Artifact {
125
124
If ($ResultRaw -ieq $False ) {
126
125
Continue
127
126
}
128
- $OutputObject = ($ResultRaw | ConvertFrom-Json - Depth 100 )
127
+ Return ($ResultRaw | ConvertFrom-Json - Depth 100 )
129
128
}
130
- ' Select' {
131
- ForEach ($Item In $Name ) {
132
- $ResultRaw = Invoke-GitHubActionsNodeJsWrapper - Path ' artifact\download.js' - InputObject ([PSCustomObject ]@ {
133
- Name = $Item
134
- Destination = $Destination
135
- CreateSubfolder = ($Name.Count -igt 1 ) ? $True : $CreateSubfolder.IsPresent
136
- } | ConvertTo-Json - Depth 100 - Compress)
137
- If ($ResultRaw -ieq $False ) {
138
- Continue
139
- }
140
- $OutputObject += ($ResultRaw | ConvertFrom-Json - Depth 100 )
129
+ ' Single' {
130
+ $ResultRaw = Invoke-GitHubActionsNodeJsWrapper - Path ' artifact\download.js' - InputObject ([PSCustomObject ]@ {
131
+ Name = $Name
132
+ Destination = $Destination
133
+ CreateSubfolder = $CreateSubfolder.IsPresent
134
+ } | ConvertTo-Json - Depth 100 - Compress)
135
+ If ($ResultRaw -ieq $False ) {
136
+ Return
141
137
}
138
+ Return ($ResultRaw | ConvertFrom-Json - Depth 100 )
142
139
}
143
140
}
144
141
}
145
- End {
146
- Return $OutputObject
147
- }
142
+ End {}
148
143
}
149
144
Set-Alias - Name ' Restore-Artifact' - Value ' Import-Artifact' - Option ' ReadOnly' - Scope ' Local'
150
145
<#
0 commit comments