Skip to content

Commit dfaae16

Browse files
jonathanpwangclaude
andcommitted
fix: use actual newlines in Slack notification strings
The $'\n' syntax produces actual newline characters that jq will properly JSON-encode, rather than literal backslash-n which would be double-escaped. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent c90324e commit dfaae16

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

.github/workflows/rebase-feature-branches.yml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,17 @@ jobs:
141141
COMMIT_MSG=$(git log -1 --pretty=format:'%s' ${{ github.sha }})
142142
COMMIT_AUTHOR=$(git log -1 --pretty=format:'%an' ${{ github.sha }})
143143
144-
# Build branch list for Slack
144+
# Build branch list for Slack (using $'\n' for actual newlines)
145145
FAILED_LIST=""
146146
for branch in $FAILED_BRANCHES; do
147-
FAILED_LIST="${FAILED_LIST}\n• \`${branch}\`"
147+
FAILED_LIST="${FAILED_LIST}"$'\n'"• \`${branch}\`"
148148
done
149149
150150
BACKUP_INFO=""
151151
if [ "$TOTAL_BACKED_UP" != "0" ]; then
152-
BACKUP_INFO="\n\n*Backups created:*"
152+
BACKUP_INFO=$'\n\n'"*Backups created:*"
153153
for backup in $BACKED_UP_BRANCHES; do
154-
BACKUP_INFO="${BACKUP_INFO}\n• \`${backup}\`"
154+
BACKUP_INFO="${BACKUP_INFO}"$'\n'"• \`${backup}\`"
155155
done
156156
fi
157157
@@ -237,25 +237,24 @@ jobs:
237237
run: |
238238
REPO_URL="${{ github.server_url }}/${{ github.repository }}"
239239
240-
# Build branch list for Slack
240+
# Build branch list for Slack (using $'\n' for actual newlines)
241241
SUCCESS_LIST=""
242242
for branch in $SUCCEEDED_BRANCHES; do
243-
SUCCESS_LIST="${SUCCESS_LIST}\n• \`${branch}\`"
243+
SUCCESS_LIST="${SUCCESS_LIST}"$'\n'"• \`${branch}\`"
244244
done
245245
246246
BACKUP_INFO=""
247247
if [ "$TOTAL_BACKED_UP" != "0" ]; then
248-
BACKUP_INFO="\n\n*Backups created:*"
248+
BACKUP_INFO=$'\n\n'"*Backups created:*"
249249
for backup in $BACKED_UP_BRANCHES; do
250-
BACKUP_INFO="${BACKUP_INFO}\n• \`${backup}\`"
250+
BACKUP_INFO="${BACKUP_INFO}"$'\n'"• \`${backup}\`"
251251
done
252252
fi
253253
254254
# Construct Slack message using jq for proper JSON escaping
255+
CONTENT="✅ *Auto-rebase completed* for <$REPO_URL|${{ github.repository }}>"$'\n\n'"*Rebased branches:*${SUCCESS_LIST}${BACKUP_INFO}"
255256
SLACK_PAYLOAD=$(jq -n \
256-
--arg repo "${{ github.repository }}" \
257-
--arg repo_url "$REPO_URL" \
258-
--arg content "✅ *Auto-rebase completed* for <$REPO_URL|${{ github.repository }}>\n\n*Rebased branches:*${SUCCESS_LIST}${BACKUP_INFO}" \
257+
--arg content "$CONTENT" \
259258
'{
260259
text: "✅ Feature Branches Rebased Successfully",
261260
blocks: [

0 commit comments

Comments
 (0)