Skip to content

Commit e96e9e0

Browse files
committed
Add functions Add-StepSummaryImage and Add-StepSummaryLink
1 parent 9f36bc6 commit e96e9e0

File tree

3 files changed

+110
-3
lines changed

3 files changed

+110
-3
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ Import-Module -Name 'hugoalh.GitHubActionsToolkit' -Prefix 'GitHubActions' -Scop
4848
- `Add-GitHubActionsProblemMatcher`
4949
- `Add-GitHubActionsSecretMask`
5050
- `Add-GitHubActionsStepSummary`
51+
- `Add-GitHubActionsStepSummaryImage`
52+
- `Add-GitHubActionsStepSummaryLink`
5153
- `Disable-GitHubActionsEchoingCommands`
5254
- `Disable-GitHubActionsProcessingCommands`
5355
- `Enable-GitHubActionsEchoingCommands`

hugoalh.GitHubActionsToolkit/hugoalh.GitHubActionsToolkit.psd1

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,8 @@
6565
'Add-ProblemMatcher',
6666
'Add-SecretMask',
6767
'Add-StepSummary',
68+
'Add-StepSummaryImage',
69+
'Add-StepSummaryLink',
6870
'Disable-EchoingCommands',
6971
'Disable-ProcessingCommands',
7072
'Enable-EchoingCommands',
@@ -104,6 +106,9 @@
104106
AliasesToExport = @(
105107
'Add-Mask',
106108
'Add-Secret',
109+
'Add-StepSummaryHyperlink',
110+
'Add-StepSummaryPicture',
111+
'Add-StepSummaryRaw',
107112
'Disable-CommandEcho',
108113
'Disable-CommandEchoing',
109114
'Disable-CommandProcess',

hugoalh.GitHubActionsToolkit/module/step-summary.psm1

Lines changed: 103 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22
#Requires -Version 7.2
33
<#
44
.SYNOPSIS
5-
GitHub Actions - Add Step Summary
5+
GitHub Actions - Add Step Summary (Raw)
66
.DESCRIPTION
7-
Add some GitHub flavored Markdown for step so that it will be displayed on the summary page of a run; Can use to display and group unique content, such as test result summaries, so that viewing the result of a run does not need to go into the logs to see important information related to the run, such as failures. When a run's job finishes, the summaries for all steps in a job are grouped together into a single job summary and are shown on the run summary page. If multiple jobs generate summaries, the job summaries are ordered by job completion time.
7+
Add some GitHub flavored Markdown for step so that it will display on the summary page of a run; Can use to display and group unique content, such as test result summaries, so that viewing the result of a run does not need to go into the logs to see important information related to the run, such as failures. When a run's job finishes, the summaries for all steps in a job are grouped together into a single job summary and are shown on the run summary page. If multiple jobs generate summaries, the job summaries are ordered by job completion time.
88
.PARAMETER Value
99
Content.
1010
.PARAMETER NoNewLine
@@ -34,6 +34,100 @@ Function Add-StepSummary {
3434
Return
3535
}
3636
}
37+
Set-Alias -Name 'Add-StepSummaryRaw' -Value 'Add-StepSummary' -Option 'ReadOnly' -Scope 'Local'
38+
<#
39+
.SYNOPSIS
40+
GitHub Actions - Add Step Summary Image
41+
.DESCRIPTION
42+
Add some GitHub flavored Markdown image for step so that it will display on the summary page of a run.
43+
IMPORTANT: No support reference image!
44+
.PARAMETER Uri
45+
Image URI.
46+
.PARAMETER Title
47+
Image title.
48+
.PARAMETER AlternativeText
49+
Image alternative text.
50+
.PARAMETER Width
51+
Image width.
52+
.PARAMETER Height
53+
Image height.
54+
.PARAMETER NoNewLine
55+
Do not add a new line or carriage return to the content, the string representations of the input objects are concatenated to form the output, no spaces or newlines are inserted between the output strings, no newline is added after the last output string.
56+
#>
57+
Function Add-StepSummaryImage {
58+
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_add-githubactionsstepsummaryimage#Add-GitHubActionsStepSummaryImage')]
59+
[OutputType([Void])]
60+
Param (
61+
[Parameter(Mandatory = $True, Position = 0)][Alias('Url')][String]$Uri,
62+
[String]$Title,
63+
[Alias('AltText')][String]$AlternativeText,
64+
[ValidateRange(0, [Int32]::MaxValue)][Int32]$Width = -1,
65+
[ValidateRange(0, [Int32]::MaxValue)][Int32]$Height = -1,
66+
[Switch]$NoNewLine
67+
)
68+
If (
69+
$Width -igt -1 -or
70+
$Height -igt -1
71+
) {
72+
[String]$ResultHtml = "<img src=`"$Uri`""
73+
If ($Title.Length -igt 0) {
74+
$ResultHtml += " title=`"$Title`""
75+
}
76+
If ($AlternativeText.Length -igt 0) {
77+
$ResultHtml += " alt=`"$AlternativeText`""
78+
}
79+
If ($Width -igt -1) {
80+
$ResultHtml += " width=`"$Width`""
81+
}
82+
If ($Height -igt -1) {
83+
$ResultHtml += " height=`"$Height`""
84+
}
85+
$ResultHtml += '>'
86+
Return (Add-StepSummary -Value $ResultHtml -NoNewLine:$NoNewLine)
87+
}
88+
[String]$ResultMarkdown = "![$AlternativeText]($Uri"
89+
If ($Title.Length -igt 0) {
90+
$ResultMarkdown += " `"$Title`""
91+
}
92+
$ResultMarkdown += ')'
93+
Return (Add-StepSummary -Value $ResultMarkdown -NoNewLine:$NoNewLine)
94+
}
95+
Set-Alias -Name 'Add-StepSummaryPicture' -Value 'Add-StepSummaryImage' -Option 'ReadOnly' -Scope 'Local'
96+
<#
97+
.SYNOPSIS
98+
GitHub Actions - Add Step Summary Link
99+
.DESCRIPTION
100+
Add some GitHub flavored Markdown link for step so that it will display on the summary page of a run.
101+
IMPORTANT: No support reference link!
102+
.PARAMETER Uri
103+
Image URI.
104+
.PARAMETER Title
105+
Image title.
106+
.PARAMETER AlternativeText
107+
Image alternative text.
108+
.PARAMETER Width
109+
Image width.
110+
.PARAMETER Height
111+
Image height.
112+
.PARAMETER NoNewLine
113+
Do not add a new line or carriage return to the content, the string representations of the input objects are concatenated to form the output, no spaces or newlines are inserted between the output strings, no newline is added after the last output string.
114+
#>
115+
Function Add-StepSummaryLink {
116+
[CmdletBinding(HelpUri = 'https://github.com/hugoalh-studio/ghactions-toolkit-powershell/wiki/api_function_add-githubactionsstepsummarylink#Add-GitHubActionsStepSummaryLink')]
117+
[OutputType([Void])]
118+
Param (
119+
[Parameter(Mandatory = $True, Position = 0)][String]$Text,
120+
[Parameter(Mandatory = $True, Position = 1)][Alias('Url')][String]$Uri,
121+
[String]$Title
122+
)
123+
[String]$ResultMarkdown = "[$Text]($Uri"
124+
If ($Title.Length -igt 0) {
125+
$ResultMarkdown += " `"$Title`""
126+
}
127+
$ResultMarkdown += ')'
128+
Return (Add-StepSummary -Value $ResultMarkdown -NoNewLine:$NoNewLine)
129+
}
130+
Set-Alias -Name 'Add-StepSummaryHyperlink' -Value 'Add-StepSummaryLink' -Option 'ReadOnly' -Scope 'Local'
37131
<#
38132
.SYNOPSIS
39133
GitHub Actions - Get Step Summary
@@ -81,7 +175,7 @@ Function Remove-StepSummary {
81175
.SYNOPSIS
82176
GitHub Actions - Set Step Summary
83177
.DESCRIPTION
84-
Set some GitHub flavored Markdown for step so that it will be displayed on the summary page of a run; Can use to display and group unique content, such as test result summaries, so that viewing the result of a run does not need to go into the logs to see important information related to the run, such as failures. When a run's job finishes, the summaries for all steps in a job are grouped together into a single job summary and are shown on the run summary page. If multiple jobs generate summaries, the job summaries are ordered by job completion time.
178+
Set some GitHub flavored Markdown for step so that it will display on the summary page of a run; Can use to display and group unique content, such as test result summaries, so that viewing the result of a run does not need to go into the logs to see important information related to the run, such as failures. When a run's job finishes, the summaries for all steps in a job are grouped together into a single job summary and are shown on the run summary page. If multiple jobs generate summaries, the job summaries are ordered by job completion time.
85179
.PARAMETER Value
86180
Content.
87181
.PARAMETER NoNewLine
@@ -113,7 +207,13 @@ Function Set-StepSummary {
113207
}
114208
Export-ModuleMember -Function @(
115209
'Add-StepSummary',
210+
'Add-StepSummaryImage',
211+
'Add-StepSummaryLink',
116212
'Get-StepSummary',
117213
'Remove-StepSummary',
118214
'Set-StepSummary'
215+
) -Alias @(
216+
'Add-StepSummaryHyperlink',
217+
'Add-StepSummaryPicture',
218+
'Add-StepSummaryRaw'
119219
)

0 commit comments

Comments
 (0)