Skip to content

Commit 6b36651

Browse files
authored
Fix Slack notification (simple-login#976)
1 parent 2660c96 commit 6b36651

File tree

2 files changed

+30
-4
lines changed

2 files changed

+30
-4
lines changed

.github/changelog_configuration.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "${{CHANGELOG}}",
3-
"pr_template": "- ${{TITLE}}\n - PR: #${{NUMBER}}",
3+
"pr_template": "- ${{TITLE}} #${{NUMBER}}",
44
"empty_template": "- no changes",
55
"categories": [
66
{

.github/workflows/main.yml

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,25 +148,51 @@ jobs:
148148
env:
149149
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
150150

151+
- name: Prepare Slack notification contents
152+
if: startsWith(github.ref, 'refs/tags/v')
153+
run: |
154+
changelog=$(cat << EOH
155+
${{ steps.build_changelog.outputs.changelog }}
156+
EOH
157+
)
158+
messageWithoutNewlines=$(echo "${changelog}" | awk '{printf "%s\\n", $0}')
159+
messageWithoutDoubleQuotes=$(echo "${messageWithoutNewlines}" | sed "s/\"/'/g")
160+
echo "${messageWithoutDoubleQuotes}"
161+
162+
echo "SLACK_CHANGELOG=${messageWithoutDoubleQuotes}" >> $GITHUB_ENV
163+
151164
- name: Post notification to Slack
152165
uses: slackapi/[email protected]
153166
if: startsWith(github.ref, 'refs/tags/v')
154167
with:
155168
channel-id: ${{ secrets.SLACK_CHANNEL_ID }}
156169
payload: |
157170
{
158-
"text": "New tag generated: ${{github.ref}}\nBuild result: ${{ job.status }}",
159171
"blocks": [
172+
{
173+
"type": "header",
174+
"text": {
175+
"type": "plain_text",
176+
"text": "New tag created",
177+
"emoji": true
178+
}
179+
},
180+
{
181+
"type": "section",
182+
"text": {
183+
"type": "mrkdwn",
184+
"text": "*Tag: ${{ github.ref_name }}*"
185+
}
186+
},
160187
{
161188
"type": "section",
162189
"text": {
163190
"type": "mrkdwn",
164-
"text": "New tag generated: ${{github.ref}}\nBuild result: ${{ job.status }}\nChangelog:\n${{ steps.build_changelog.outputs.changelog }}"
191+
"text": "*Changelog:*\n${{ env.SLACK_CHANGELOG }}"
165192
}
166193
}
167194
]
168195
}
169-
slack-message: ""
170196
env:
171197
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
172198

0 commit comments

Comments
 (0)