Skip to content

Commit 98709ac

Browse files
committed
20220626B
1 parent 6b31b16 commit 98709ac

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

hugoalh.GitHubActionsToolkit/module/cache.psm1

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,10 @@ Function Save-Cache {
120120
[ValidateRange(1, 16)][AllowNull()][Byte]$UploadConcurrency = $Null
121121
)
122122
Begin {
123+
If (!(Test-GitHubActionsEnvironment -Cache)) {
124+
Return (Write-Error -Message 'Unable to get GitHub Actions cache resources!' -Category 'ResourceUnavailable')
125+
Break# This is the best way to early terminate this function without terminate caller/invoker process.
126+
}
123127
[String[]]$PathsProceed = @()
124128
}
125129
Process {
@@ -135,9 +139,6 @@ Function Save-Cache {
135139
}
136140
}
137141
End {
138-
If (!(Test-GitHubActionsEnvironment -Cache)) {
139-
Return (Write-Error -Message 'Unable to get GitHub Actions cache resources!' -Category 'ResourceUnavailable')
140-
}
141142
If ($PathsProceed.Count -ieq 0) {
142143
Return (Write-Error -Message 'No valid path is defined!' -Category 'NotSpecified')
143144
}

hugoalh.GitHubActionsToolkit/module/step-summary.psm1

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ Function Add-StepSummary {
2323
[Switch]$NoNewLine
2424
)
2525
Begin {
26+
If (!(Test-GitHubActionsEnvironment -StepSummary)) {
27+
Return (Write-Error -Message 'Unable to get GitHub Actions step summary resources!' -Category 'ResourceUnavailable')
28+
Break# This is the best way to early terminate this function without terminate caller/invoker process.
29+
}
2630
[String[]]$Result = @()
2731
}
2832
Process {
@@ -31,9 +35,6 @@ Function Add-StepSummary {
3135
}
3236
}
3337
End {
34-
If (!(Test-GitHubActionsEnvironment -StepSummary)) {
35-
Return (Write-Error -Message 'Unable to get GitHub Actions step summary resources!' -Category 'ResourceUnavailable')
36-
}
3738
If ($Result.Count -igt 0) {
3839
Add-Content -LiteralPath $Env:GITHUB_STEP_SUMMARY -Value ($Result -join "`n") -Confirm:$False -NoNewline:$NoNewLine.IsPresent -Encoding 'UTF8NoBOM'
3940
}
@@ -271,6 +272,10 @@ Function Set-StepSummary {
271272
[Switch]$NoNewLine
272273
)
273274
Begin {
275+
If (!(Test-GitHubActionsEnvironment -StepSummary)) {
276+
Return (Write-Error -Message 'Unable to get GitHub Actions step summary resources!' -Category 'ResourceUnavailable')
277+
Break# This is the best way to early terminate this function without terminate caller/invoker process.
278+
}
274279
[String[]]$Result = @()
275280
}
276281
Process {
@@ -279,9 +284,6 @@ Function Set-StepSummary {
279284
}
280285
}
281286
End {
282-
If (!(Test-GitHubActionsEnvironment -StepSummary)) {
283-
Return (Write-Error -Message 'Unable to get GitHub Actions step summary resources!' -Category 'ResourceUnavailable')
284-
}
285287
If ($Result.Count -igt 0) {
286288
Set-Content -LiteralPath $Env:GITHUB_STEP_SUMMARY -Value ($Result -join "`n") -Confirm:$False -NoNewline:$NoNewLine.IsPresent -Encoding 'UTF8NoBOM'
287289
}

hugoalh.GitHubActionsToolkit/module/tool-cache.psm1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ Function Invoke-ToolCacheToolDownloader {
114114
Begin {
115115
If (!(Test-GitHubActionsEnvironment -ToolCache)) {
116116
Return (Write-Error -Message 'Unable to get GitHub Actions tool cache resources!' -Category 'ResourceUnavailable')
117+
Break# This is the best way to early terminate this function without terminate caller/invoker process.
117118
}
118119
[String[]]$OutputObject = @()
119120
}

0 commit comments

Comments
 (0)