@@ -22,38 +22,48 @@ jobs:
22
22
23
23
- name : Run solutions
24
24
run : |
25
- IFS=$'\n' read -r -d '' -a results < <(go run main.go && printf '\0')
26
- echo "AOC_RESULT=${#results[@]}" >> $GITHUB_ENV
25
+ # Capture output in a more reliable way
26
+ output=$(go run main.go)
27
+ echo "$output"
28
+
29
+ # Get the STARS value from the last line
30
+ stars=$(echo "$output" | grep "STARS=" | cut -d'=' -f2)
31
+ echo "AOC_RESULT=$stars" >> $GITHUB_ENV
32
+
33
+ # Store all results
27
34
echo "RESULTS<<EOF" >> $GITHUB_ENV
28
- printf "%s\n" "${results[@]} " >> $GITHUB_ENV
35
+ echo "$output " >> $GITHUB_ENV
29
36
echo "EOF" >> $GITHUB_ENV
30
37
31
38
- name : Update README progress
32
39
run : |
33
40
progress=$(cat README.md)
34
41
stars=${{ env.AOC_RESULT }}
35
- IFS=$'\n' read -r -d '' -a results <<< "${{ env.RESULTS }}"
42
+
43
+ # Fix the results array parsing
44
+ readarray -t results < <(echo "${{ env.RESULTS }}" | grep "DAY")
36
45
37
46
# Create new progress table with results
38
47
new_table="| Day | Results | Stars |\n|:---:|:-------:|:-----:|\n"
39
48
current_day=1
40
- for ((i=0; i<${#results[@]}; i+=2)); do
41
- p1="${results[i]:-}"
42
- p2="${results[i+1]:-}"
49
+ i=0
50
+ while [ $i -lt ${#results[@]} ]; do
51
+ p1=$(echo "${results[$i]}" | grep "DAY.*P1" | cut -d'=' -f2)
52
+ p2=$(echo "${results[$((i+1))]}" | grep "DAY.*P2" | cut -d'=' -f2)
43
53
44
54
result_text=""
45
55
star=""
46
56
47
57
if [ -n "$p1" ] && [ -n "$p2" ]; then
48
58
result_text="P1: $p1, P2: $p2"
49
- star=" ⭐" # Only one star when both parts are done
59
+ star=" ⭐"
50
60
elif [ -n "$p1" ]; then
51
61
result_text="P1: $p1"
52
- star="" # No star for partial completion
53
62
fi
54
63
55
64
new_table+="| [Day $current_day](aoc24/day$current_day) | $result_text | $star |\n"
56
65
((current_day++))
66
+ ((i+=2))
57
67
done
58
68
59
69
# Fill remaining days
0 commit comments