@@ -92,52 +92,41 @@ function Update-MDSection {
9292
9393 # The new content to insert between the section markers.
9494 [Parameter ()]
95- [string ] $Content ,
96-
97- # Skip update when the target file or section markers are missing.
98- [Parameter ()]
99- [switch ] $SkipIfMissing
95+ [string ] $Content
10096 )
10197
10298 $startSegment = " <!-- $Name `_START -->"
10399 $endSegment = " <!-- $Name `_END -->"
104100
105- if (-not (Test-Path - Path $Path )) {
106- if ($SkipIfMissing ) {
107- Write-Warning " [$Name ] Skipping update because target file was not found: $Path "
108- return
101+ function Write-UpdateWarning {
102+ param ([string ] $Message )
103+
104+ Write-Warning $Message
105+ if ($env: GITHUB_ACTIONS -eq ' true' ) {
106+ Write-Output " ::warning::$Message "
109107 }
108+ }
110109
111- throw " [$Name ] Target file was not found: $Path "
110+ if (-not (Test-Path - Path $Path )) {
111+ Write-UpdateWarning " [$Name ] Skipping update because target file was not found: $Path "
112+ return
112113 }
113114
114115 $currentContent = Get-Content - Path $Path
115116 $startIndex = $currentContent.IndexOf ($startSegment )
116117 $endIndex = $currentContent.IndexOf ($endSegment )
117118
118119 if ($startIndex -lt 0 ) {
119- if ($SkipIfMissing ) {
120- Write-Warning " [$Name ] Skipping update because the start marker was not found in: $Path "
121- return
122- }
123-
124- throw " [$Name ] The start comment segment was not found in the file."
120+ Write-UpdateWarning " [$Name ] Skipping update because the start marker was not found in: $Path "
121+ return
125122 }
126123 if ($endIndex -lt 0 ) {
127- if ($SkipIfMissing ) {
128- Write-Warning " [$Name ] Skipping update because the end marker was not found in: $Path "
129- return
130- }
131-
132- throw " [$Name ] The end comment segment was not found in the file."
124+ Write-UpdateWarning " [$Name ] Skipping update because the end marker was not found in: $Path "
125+ return
133126 }
134127 if ($endIndex -lt $startIndex ) {
135- if ($SkipIfMissing ) {
136- Write-Warning " [$Name ] Skipping update because marker order is invalid in: $Path "
137- return
138- }
139-
140- throw " [$Name ] The end comment segment was found before the start comment segment."
128+ Write-UpdateWarning " [$Name ] Skipping update because marker order is invalid in: $Path "
129+ return
141130 }
142131
143132 $updatedContent = $currentContent [0 .. $startIndex ] + $Content + $currentContent [($endIndex ).. ($currentContent.Length - 1 )]
@@ -202,7 +191,7 @@ function Update-ActionList {
202191$actionTableRows </table>
203192
204193"@
205- Update-MDSection - Path ' .\src\docs\GitHub-Actions\index.md' - Name ' ACTION_LIST' - Content $actionTable - SkipIfMissing
194+ Update-MDSection - Path ' .\src\docs\GitHub-Actions\index.md' - Name ' ACTION_LIST' - Content $actionTable
206195}
207196
208197function Update-ModuleList {
@@ -258,7 +247,7 @@ $moduleTableRows</table>
258247
259248"@
260249
261- Update-MDSection - Path ' .\src\docs\PowerShell\Modules\index.md' - Name ' MODULE_LIST' - Content $moduleTable - SkipIfMissing
250+ Update-MDSection - Path ' .\src\docs\PowerShell\Modules\index.md' - Name ' MODULE_LIST' - Content $moduleTable
262251}
263252
264253function Update-FunctionAppList {
@@ -318,5 +307,5 @@ $functionAppTableRows</table>
318307
319308"@
320309
321- Update-MDSection - Path ' .\src\docs\PowerShell\FunctionApps\index.md' - Name ' FUNCTIONAPP_LIST' - Content $functionAppTable - SkipIfMissing
310+ Update-MDSection - Path ' .\src\docs\PowerShell\FunctionApps\index.md' - Name ' FUNCTIONAPP_LIST' - Content $functionAppTable
322311}
0 commit comments