Skip to content

Commit b3a1fa2

Browse files
committed
🔧 (main.yaml, ImagesToBlobStorage.ps1): improve logging and return count of deleted images
Remove trailing whitespace in the Hugo setup step for consistency. Capture the count of deleted images in the Delete-LocalImageFiles function and log this information. This change enhances the transparency of the image deletion process by providing a count of deleted images, which can be useful for monitoring and debugging purposes. Additionally, the logging level for individual file deletions is changed from info to debug to reduce verbosity in standard logs.
1 parent 07230be commit b3a1fa2

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

‎.github/workflows/main.yaml

+3-2
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ jobs:
228228
- name: Setup Hugo
229229
uses: peaceiris/actions-hugo@v3
230230
with:
231-
hugo-version: "${{ vars.HUGO_BUILD_VERSION }}"
231+
hugo-version: "${{ vars.HUGO_BUILD_VERSION }}"
232232
extended: true
233233

234234
- name: Build
@@ -341,7 +341,8 @@ jobs:
341341
shell: pwsh
342342
run: |
343343
. ./.powershell/_includes/ImagesToBlobStorage.ps1
344-
Delete-LocalImageFiles -LocalPath $env:LOCAL_IMAGE_PATH
344+
$deletedImagesCount = Delete-LocalImageFiles -LocalPath $env:LOCAL_IMAGE_PATH
345+
345346
env:
346347
LOCAL_IMAGE_PATH: "./_site/"
347348
# - name: "Build NKDAgility Outputs"

‎.powershell/_includes/ImagesToBlobStorage.ps1

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@ function Delete-LocalImageFiles {
2626
param (
2727
[string]$LocalPath
2828
)
29+
$count = 0
2930
try {
3031
Write-InfoLog "Deleting all image files locally..."
3132
Get-ChildItem -Path $LocalPath -Recurse -Include *.jpg, *.jpeg, *.png, *.gif, *.webp, *.svg | ForEach-Object {
3233
try {
34+
$count++
3335
Remove-Item -Path $_.FullName -Force
34-
Write-InfoLog "Deleted: $($_.FullName)"
36+
Write-DebugLog "Deleted: $($_.FullName)"
3537
}
3638
catch {
3739
Write-ErrorLog "Error deleting file $($_.FullName): $_"
@@ -41,6 +43,8 @@ function Delete-LocalImageFiles {
4143
catch {
4244
Write-ErrorLog "Error during file deletion: $_"
4345
}
46+
Write-InfoLog "Deleted: $count"
47+
return $count;
4448
}
4549

4650
# Method 3: Rewrite image links in .html files using regex

0 commit comments

Comments
 (0)