Discussion to Slack Notification #2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Discussion to Slack Notification | |
on: | |
discussion: | |
types: [created] | |
jobs: | |
notify-slack: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Get discussion details | |
id: discussion-details | |
run: | | |
echo "title=${{ github.event.discussion.title }}" >> $GITHUB_OUTPUT | |
echo "body=${{ github.event.discussion.body }}" >> $GITHUB_OUTPUT | |
echo "url=${{ github.event.discussion.html_url }}" >> $GITHUB_OUTPUT | |
echo "author=${{ github.event.discussion.user.login }}" >> $GITHUB_OUTPUT | |
echo "category=${{ github.event.discussion.category.name }}" >> $GITHUB_OUTPUT | |
- name: Post to Slack channel | |
id: slack | |
uses: slackapi/[email protected] | |
with: | |
channel-id: ${{ secrets.SLACK_CHANNEL_ID }} | |
slack-message: | | |
:speech_balloon: New Discussion Created :speech_balloon: | |
*Title:* ${{ steps.discussion-details.outputs.title }} | |
*Author:* ${{ steps.discussion-details.outputs.author }} | |
*Category:* ${{ steps.discussion-details.outputs.category }} | |
*Link:* ${{ steps.discussion-details.outputs.url }} | |
*Discussion Body:* | |
``` | |
${{ steps.discussion-details.outputs.body }} | |
``` | |
env: | |
SLACK_BOT_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }} |