Skip to content

Commit fab5c2c

Browse files
committed
fix(ci): fix slack message format with color
1 parent a82f800 commit fab5c2c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

.github/workflows/common-testing.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -298,19 +298,27 @@ jobs:
298298
cat ~/.aws/config &&
299299
RUST_BACKTRACE=full cargo test ${ARGS_TESTS:+$ARGS_TESTS}
300300
301+
- name: Set Slack color
302+
id: slack_color
303+
run: |
304+
if [ "${{ steps.tests.outcome }}" = "success" ]; then
305+
echo "color=good" >> $GITHUB_OUTPUT
306+
else
307+
echo "color=danger" >> $GITHUB_OUTPUT
308+
fi
309+
301310
- name: Post a message in a channel
302311
uses: slackapi/slack-github-action@91efab103c0de0a537f72a35f6b8cda0ee76bf0a # v2.1.1
303312
env:
304313
ACTION_RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
305314
SLACK_ICON: ":github-octocat:"
306315
SLACK_TITLE: "GitHub Action tests result"
307-
SLACK_COLOR: ${{ steps.tests.outcome == 'success' && 'good' || 'danger' }}
308316
with:
309317
webhook: ${{ secrets.SLACK_WEBHOOK_URL }}
310318
webhook-type: incoming-webhook
311319
payload: |
312320
attachments:
313-
- color: "${{ env.SLACK_COLOR }}"
321+
- color: "${{ steps.slack_color.outputs.color }}"
314322
blocks:
315323
- type: "section"
316324
text:

0 commit comments

Comments
 (0)