name: Post Announcements to Slack on: discussion: types: [created, edited] jobs: notify-slack: runs-on: ubuntu-latest steps: - name: Check if announcement id: check run: | # Check if the discussion is in the announcements category CATEGORY="${{ github.event.discussion.category.slug }}" echo "Category: $CATEGORY" # Check for both possible variations if [ "$CATEGORY" = "announcements" ] || [ "$CATEGORY" = "announcement" ]; then echo "is_announcement=true" >> $GITHUB_OUTPUT else echo "is_announcement=false" >> $GITHUB_OUTPUT fi - name: Post to Slack if: steps.check.outputs.is_announcement == 'true' uses: slackapi/slack-github-action@v1 with: payload: | { "text": "New Announcement: ${{ github.event.discussion.title }}", "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "*${{ github.event.discussion.title }}*\n${{ github.event.discussion.body }}" } }, { "type": "section", "text": { "type": "mrkdwn", "text": "<${{ github.event.discussion.html_url }}|View Discussion>" } } ] } env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DOGRAH_COMMUNITY_WEBHOOK_URL }}