@@ -102,16 +102,18 @@ jobs:
102102 JSON_PAYLOAD=$(jq -n \
103103 --arg segment_id "$RESEND_SEGMENT_ID" \
104104 --arg from "dropalltables <blog@system.viruus.zip>" \
105+ --arg name "$TITLE" \
105106 --arg subject "$TITLE" \
106107 --argjson text "$POST_CONTENT_ESCAPED" \
107108 '{
108109 segment_id: $segment_id,
109110 from: $from,
111+ name: $name,
110112 subject: $subject,
111113 text: $text
112114 }')
113115
114- # Send email via Resend API
116+ # Create broadcast via Resend API
115117 RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "https://api.resend.com/broadcasts" \
116118 -H "Authorization: Bearer $RESEND_API_KEY" \
117119 -H "Content-Type: application/json" \
@@ -122,11 +124,25 @@ jobs:
122124
123125 if [ "$HTTP_CODE" = "200" ] || [ "$HTTP_CODE" = "201" ]; then
124126 BROADCAST_ID=$(echo "$RESPONSE_BODY" | jq -r '.id // "unknown"')
125- echo " Email sent successfully"
126- echo " Broadcast ID: $BROADCAST_ID"
127- ((EMAILS_SENT++))
127+ echo " Broadcast created: $BROADCAST_ID"
128+
129+ # Send the broadcast
130+ SEND_RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "https://api.resend.com/broadcasts/$BROADCAST_ID/send" \
131+ -H "Authorization: Bearer $RESEND_API_KEY")
132+
133+ SEND_HTTP_CODE=$(echo "$SEND_RESPONSE" | tail -n 1)
134+
135+ if [ "$SEND_HTTP_CODE" = "200" ] || [ "$SEND_HTTP_CODE" = "201" ]; then
136+ echo " Email sent successfully"
137+ ((EMAILS_SENT++))
138+ else
139+ SEND_RESPONSE_BODY=$(echo "$SEND_RESPONSE" | head -n -1)
140+ echo " Error sending broadcast (HTTP $SEND_HTTP_CODE)"
141+ echo " Response: $SEND_RESPONSE_BODY"
142+ ((EMAILS_SKIPPED++))
143+ fi
128144 else
129- echo " Error sending email (HTTP $HTTP_CODE)"
145+ echo " Error creating broadcast (HTTP $HTTP_CODE)"
130146 echo " Response: $RESPONSE_BODY"
131147 ((EMAILS_SKIPPED++))
132148 fi
@@ -135,3 +151,4 @@ jobs:
135151 done <<< "$NEW_FILES"
136152
137153 echo "Summary: $EMAILS_SENT email(s) sent, $EMAILS_SKIPPED skipped"
154+ exit 0
0 commit comments