Skip to content

Body not formatted as markdown #461

Open

Description

@arelstone

When creating a release using the auto generated release notes, which is markdown. The body ${{ github.release.event.body }} is not being formatted as expected

Workflow

on:
  release:
    types: 
      - released
      - prereleased
jobs:
  notify:
    runs-on: ubuntu-latest
    steps:
      - run: echo "${{ github.event.release.body || 'No release body provided' }}"
        shell: bash
      - run: |
          echo "Release event detected: ${{ github.event_name }}"
          echo "Release name: ${{ github.event.release.name || github.event.release.tag_name }}"
          echo "Release body: ${{ github.event.release.body }}"
          echo "Release URL: ${{ github.event.release.html_url }}"
          echo "Release is a pre-release: ${{ github.event.release.prerelease }}"
          echo "Workflow run ID: ${{ github.run_id }}"
          echo "Repository: ${{ github.repository }}"
          echo "Server URL: ${{ github.server_url }}"
          

      - name: Send Slack Notification
        uses: slackapi/slack-github-action@v2.1.0
        with:
          webhook-type: incoming-webhook
          webhook: "${{ secrets.SLACK_WEBHOOK_URL }}"
          payload: |
            text: "🚀 🔖 ✨ Release notice ${{ github.event.release.name || github.event.release.tag_name }} ✨ 🔖 🚀"
            blocks:
              - type: "section"
                text:
                  type: "mrkdwn"
                  text: "*🚀 🔖 ✨ Release notice ${{ github.event.release.name || github.event.release.tag_name }} ✨ 🔖 🚀*"
              - type: "context"
                elements: 
                  - type: "mrkdwn"
                    text: "*Build for*: ${{ github.event.release.prerelease && 'Stage' || 'Production' }}"
                  - type: "mrkdwn"
                    text: "*Version*: ${{ github.event.release.tag_name }}"
              - type: "divider"
              - type: "section"
                text: 
                  type: "mrkdwn"
                  text: "${{ github.event.release.body }}"
              - type: "divider"
              - type: "context"
                elements: 
                  - type: "mrkdwn"
                    text: "<${{ github.event.release.html_url }}|*Full Changelog*>"
                  - type: "mrkdwn"
                    text: "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow Run>"      

Expected:

Image

Recieved:

Image

Activity

  1. changed the title [-]Body of github release is not formatted as markdown[/-] [+]Body not formatted as markdown[/+] on Jun 19, 2025
  2. added
    bug
    duplicate
    question
    on Jun 19, 2025
  3. zimeg commented on Jun 19, 2025

    @zimeg
    Member

    Hey @arelstone! 👋 Thanks for sharing this finding with a code snippet 📚 ✨

    A small difference between mrkdwn formatting and the markdown block might be causing this unexpected output and can be updated inline as:

    - - type: "section"
    -   text: 
    -     type: "mrkdwn"
    -     text: "${{ github.event.release.body }}"
    + - type: "markdown"
    +   text: "${{ github.event.release.body }}"

    However this might fail to send due to an ongoing server side issue - we're keeping track of errors sending markdown with incoming webhooks in #440.

    A possible workaround for now might use the chat.postMessage method and technique for block messages 👾

  4. arelstone commented on Jun 20, 2025

    @arelstone
    Author

    Thank you @zimeg for the quick reply. And thank you very much on the clarification.

    Changing the workflow to use chat.postMessage worked. Using chat.postMessage I could not use the markdown type. Had to change back to mrkdwn and do a sed on the release body, which is not ideal.... But it works

    on:
      release:
        types: 
          - released
          - prereleased
    jobs:
      notify:
        runs-on: ubuntu-latest
        steps:
          - name: Print Release Information
            run: |
              echo "${{ github.event.release.body }}"
              echo "Release event detected: ${{ github.event_name }}"
              echo "Release name: ${{ github.event.release.name || github.event.release.tag_name }}"
              echo "Release body: ${{ github.event.release.body }}"
              echo "Release URL: ${{ github.event.release.html_url }}"
              echo "Release is a pre-release: ${{ github.event.release.prerelease }}"
              echo "Workflow run ID: ${{ github.run_id }}"
              echo "Repository: ${{ github.repository }}"
              echo "Server URL: ${{ github.server_url }}"
    
          - name: Sanitize body
            id: sanitize_body
            run: |
              echo "Sanitizing release body..."
              sanitized_body=$(echo "${{ github.event.release.body }}" | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g')
              echo "--------"
              echo "$sanitized_body"
              echo "--------"
              echo "BODY=$sanitized_body" >> $GITHUB_ENV
            
    
          - name: Send Slack Notification
            if: always()
            uses: slackapi/slack-github-action@v2.1.0
            with:
              method: chat.postMessage
              token: ${{ secrets.SLACK_BOT_TOKEN }}
              payload: |
                channel: "_____"
                text: "🚀 🔖 ✨ Release notice ${{ github.event.release.name || github.event.release.tag_name }} ✨ 🔖 🚀"
                blocks:
                  - type: "section"
                    text:
                      type: "mrkdwn"
                      text: "*🚀 🔖 ✨ Release notice ${{ github.event.release.name || github.event.release.tag_name }} ✨ 🔖 🚀*"
                  - type: "context"
                    elements: 
                      - type: "mrkdwn"
                        text: "*Build for*: ${{ github.event.release.prerelease && 'Stage' || 'Production' }}"
                      - type: "mrkdwn"
                        text: "*Version*: ${{ github.event.release.tag_name }}"
                  - type: "divider"
                  - type: "section"
                    text: 
                      type: "mrkdwn"
                      text: "${{ env.BODY }}"
                  - type: "divider"
                  - type: "context"
                    elements: 
                      - type: "mrkdwn"
                        text: "<${{ github.event.release.html_url }}|*Full Changelog*>"
                      - type: "mrkdwn"
                        text: "<${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}|View Workflow Run>"               
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugduplicatequestionserver-side issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions