@@ -38,22 +38,30 @@ jobs:
3838 run : |
3939 # Capture the output from the ContentLoader
4040 output=$(dotnet run --project ContentLoader/ContentLoader.csproj --configuration Release -- Content 2>&1)
41- echo "$output"
42-
43- # Extract sync summary numbers using grep and sed
44- added=$(echo "$output" | grep "Added:" | sed 's/Added: *\([0-9]*\)/\1/')
45- updated=$(echo "$output" | grep "Updated:" | sed 's/Updated: *\([0-9]*\)/\1/')
46- unchanged=$(echo "$output" | grep "Unchanged:" | sed 's/Unchanged: *\([0-9]*\)/\1/')
47- failed=$(echo "$output" | grep "Failed:" | sed 's/Failed: *\([0-9]*\)/\1/')
48- total=$(echo "$output" | grep "Total:" | sed 's/Total: *\([0-9]*\)/\1/')
41+ echo "$output" # Extract sync summary numbers using awk for more reliable parsing
42+ added=$(echo "$output" | awk '/Added:/ {print $2}')
43+ updated=$(echo "$output" | awk '/Updated:/ {print $2}')
44+ unchanged=$(echo "$output" | awk '/Unchanged:/ {print $2}')
45+ failed=$(echo "$output" | awk '/Failed:/ {print $2}')
46+ total=$(echo "$output" | awk '/Total:/ {print $2}')
47+
48+ # Fallback to 0 if extraction failed
49+ added=${added:-0}
50+ updated=${updated:-0}
51+ unchanged=${unchanged:-0}
52+ failed=${failed:-0}
53+ total=${total:-0}
54+
55+ # Debug output
56+ echo "Extracted values: added=$added, updated=$updated, unchanged=$unchanged, failed=$failed, total=$total"
4957
5058 # Set outputs for the next steps
5159 echo "added=$added" >> $GITHUB_OUTPUT
5260 echo "updated=$updated" >> $GITHUB_OUTPUT
5361 echo "unchanged=$unchanged" >> $GITHUB_OUTPUT
54- echo "failed=$failed" >> $GITHUB_OUTPUT echo "total=$total" >> $GITHUB_OUTPUT
55-
56- # Check if upload failed
62+ echo "failed=$failed" >> $GITHUB_OUTPUT
63+ echo "total=$total" >> $GITHUB_OUTPUT
64+ # Check if upload failed
5765 if [ "$failed" != "0" ]; then
5866 echo "Content upload failed with $failed failures"
5967 exit 1
@@ -62,14 +70,25 @@ jobs:
6270 - name : Create Content Sync Summary
6371 if : always()
6472 run : |
65- # Get the values from the previous step
73+ # Get the values from the previous step with fallback defaults
6674 added="${{ steps.upload-content.outputs.added }}"
6775 updated="${{ steps.upload-content.outputs.updated }}"
6876 unchanged="${{ steps.upload-content.outputs.unchanged }}"
6977 failed="${{ steps.upload-content.outputs.failed }}"
7078 total="${{ steps.upload-content.outputs.total }}"
7179 article_count="${{ steps.count-articles.outputs.article-count }}"
7280
81+ # Ensure all values are numbers (fallback to 0 if empty)
82+ added=${added:-0}
83+ updated=${updated:-0}
84+ unchanged=${unchanged:-0}
85+ failed=${failed:-0}
86+ total=${total:-0}
87+ article_count=${article_count:-0}
88+
89+ # Debug output
90+ echo "Summary values: added=$added, updated=$updated, unchanged=$unchanged, failed=$failed, total=$total, article_count=$article_count"
91+
7392 # Calculate success rate
7493 if [ "$total" -gt 0 ]; then
7594 success_rate=$(( (total - failed) * 100 / total ))
0 commit comments