4343 echo 'EOF'
4444 } >> "$GITHUB_ENV"
4545
46+ - name : Write commits to file
47+ if : env.SKIP_NOTIFICATION != 'true'
48+ run : |
49+ cat << 'COMMITS_EOF' > /tmp/commits.txt
50+ ${{ env.COMMITS }}
51+ COMMITS_EOF
52+
4653 - name : Post to Discord (smart split)
4754 if : env.SKIP_NOTIFICATION != 'true'
4855 run : |
@@ -57,13 +64,15 @@ jobs:
5764 "
5865
5966 MAX_LEN=1900 # Leave buffer for safety
60- HEADER_LEN=${#HEADER}
6167
6268 # Split commits into chunks
6369 CURRENT_CHUNK=""
6470 CHUNK_NUM=1
6571
66- while IFS= read -r line; do
72+ while IFS= read -r line || [ -n "$line" ]; do
73+ # Skip empty lines
74+ [ -z "$line" ] && continue
75+
6776 TEST_MSG="${HEADER}${CURRENT_CHUNK}${line}"$'\n'
6877
6978 if [ ${#TEST_MSG} -gt $MAX_LEN ] && [ -n "$CURRENT_CHUNK" ]; then
7584 fi
7685
7786 curl -H "Content-Type: application/json" \
78- -d "{\"content\": $(echo "$MESSAGE" | jq -Rs .), \"flags\": 4}" \
87+ -d "{\"content\": $(printf '%s' "$MESSAGE" | jq -Rs .), \"flags\": 4}" \
7988 "${{ secrets.DISCORD_WEBHOOK }}"
8089
8190 sleep 1 # Rate limit protection
8493 else
8594 CURRENT_CHUNK="${CURRENT_CHUNK}${line}"$'\n'
8695 fi
87- done <<< "${{ env.COMMITS }}"
96+ done < /tmp/commits.txt
8897
8998 # Send final chunk
9099 if [ -n "$CURRENT_CHUNK" ]; then
95104 fi
96105
97106 curl -H "Content-Type: application/json" \
98- -d "{\"content\": $(echo "$MESSAGE" | jq -Rs .), \"flags\": 4}" \
107+ -d "{\"content\": $(printf '%s' "$MESSAGE" | jq -Rs .), \"flags\": 4}" \
99108 "${{ secrets.DISCORD_WEBHOOK }}"
100109 fi
0 commit comments