Skip to content

Commit 4dcd8eb

Browse files
committed
build: escaping release notes
1 parent 3e91b14 commit 4dcd8eb

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

.github/workflows/release.yml

+22-2
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,34 @@ jobs:
1313
contents: read
1414
runs-on: ubuntu-latest
1515
steps:
16+
# Preprocess the release body to escape newlines and set as an output variable
17+
- name: Prepare Release Body
18+
id: prepare_body
19+
run: |
20+
printf "${{ github.event.release.body }}" > changes.txt
21+
sed -i ':a;N;$!ba;s/\\/\\\\/g; s/"/\\"/g; s/\n/\\n/g; s/\r//g; s/\t/\\t/g' changes.txt
22+
sed -i -E 's/\(#([0-9]+)\)/([#\1](https:\/\/github.com\/FgForrest\/evitaDB\/issues\/\1))/g' changes.txt
23+
echo "Contents of the file:"
24+
cat changes.txt
25+
echo ""
26+
sanitized_body=$(< changes.txt)
27+
echo "processed_body=$sanitized_body" >> $GITHUB_OUTPUT
28+
29+
# Send the message to Mattermost with the escaped release body
1630
- name: Send message to Mattermost
1731
uses: mattermost/action-mattermost-notify@b7d118e440bf2749cd18a4a8c88e7092e696257a # v2.0.0
1832
with:
1933
MATTERMOST_WEBHOOK_URL: ${{ secrets.MM_WEBHOOK_URL }}
2034
PAYLOAD: |-
2135
{
22-
"text": "## 🎉 evitaDB ${{ github.event.release.tag_name }} released!\n\n**Release Notes**:\\n ${{ toJSON(github.event.release.body) }}",
23-
"color":"#31bf2c",
36+
"attachments": [
37+
{
38+
"title": "🎉 evitaDB ${{ github.event.release.name }} released!",
39+
"title_link": "${{ github.event.release.html_url }}",
40+
"text": "${{ steps.prepare_body.outputs.processed_body }}",
41+
"color": "#31bf2c"
42+
}
43+
],
2444
"username": "${{ github.triggering_actor }}",
2545
"icon": "https://raw.githubusercontent.com/FgForrest/evitaDB/dev/documentation/assets/img/evita.png"
2646
}

0 commit comments

Comments
 (0)