File tree Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Expand file tree Collapse file tree 1 file changed +42
-0
lines changed Original file line number Diff line number Diff line change 1+ name : Notify Slack on release
2+
3+ on :
4+ release :
5+ types : [published]
6+
7+ jobs :
8+ slack_notify :
9+ runs-on : ubuntu-latest
10+ steps :
11+ - name : Format and send Slack message
12+ env :
13+ SLACK_WEBHOOK_URL : ${{ secrets.SLACK_WEBHOOK_URL }}
14+ REPO : ${{ github.repository }}
15+ TAG : ${{ github.event.release.tag_name }}
16+ TITLE : ${{ github.event.release.name }}
17+ URL : ${{ github.event.release.html_url }}
18+ RAW_BODY : ${{ github.event.release.body }}
19+ run : |
20+ # Transform markdown to Slack format
21+ CLEANED_BODY=$(echo "$RAW_BODY" \
22+ | sed -E 's/^### (.*)$/*\1*/' \
23+ | sed -E 's/^## (.*)$/*\1*/' \
24+ | sed -E 's/^# (.*)$/*\1*/' \
25+ | sed -E 's/^- (.*)$/• \1/' \
26+ | sed -E 's/\r//' \
27+ )
28+
29+ SLACK_MESSAGE="🚀 *New release!*
30+
31+ ➡️ $TITLE
32+ 🔗 $URL
33+
34+ $CLEANED_BODY"
35+
36+ # Generate the JSON
37+ echo '{}' | jq --arg text "$SLACK_MESSAGE" '.text = $text' > payload.json
38+
39+ cat payload.json
40+ curl -X POST -H 'Content-type: application/json' \
41+ --data @payload.json \
42+ "$SLACK_WEBHOOK_URL"
You can’t perform that action at this time.
0 commit comments