Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Line breaks and lists in message #94

Closed
m-ibot opened this issue Jul 31, 2024 · 2 comments
Closed

Line breaks and lists in message #94

m-ibot opened this issue Jul 31, 2024 · 2 comments

Comments

@m-ibot
Copy link

m-ibot commented Jul 31, 2024

Hello!

First, I want to tell I really like this action! I migrated to it because it Microsoft disabled the MS-Teams connectors and I needed to switch to the workflow solution with Adaptive Cards. This action displays build information really nice!

There is only one thing and I'm not sure if it is a bug or if I do not escape characters correctly.

To display the message, you use a TextBlock element:

{
"type": "TextBlock",
"text": this.message,
"wrap": true,
},

Based on the Microsoft documentation, several markdown formats are supported by TextBlocks in Adaptive cards: Format cards with Markdown

While I was able to use bold, italic and hyper links, I was not able to use list (ordered and unordered) or line breaks in the message block. Lists items were all displayed in one line and the line break characters (\r, \n, \n\n) were displayed in the message.

Is this a feature this is currently not supported by this action (If so, would this be a possible enhancement?) or do I need some special escaping?

Thank you and best regards!

@neonidian
Copy link
Owner

Hi @m-ibot

Thank you for using this action and for your feedback. I tested this action with updating the tests to list and the formatting looks fine like in this screenshot. The examples are in here and here.
multi-line-list

Could you try out again from your end. Make sure to enclose the entire formatting in double quotes. If it doesn't work, can you send me the message that you send(the sensitive info masked of course) and i can try it out from my end.

@m-ibot
Copy link
Author

m-ibot commented Aug 1, 2024

Hi @neonidian,

thank you for your help. I was able to format messages.

Workflow-Definition:

name: Send MS Teams message

on:
  workflow_dispatch:

jobs:
  send-messages:
    name: Send Messages to MS Teams
    runs-on: ubuntu-latest
    steps:
      - name: single-fail
        uses: neonidian/teams-notify-build-status@v4
        with:
          webhookUrl: ${{ secrets.TEAMS_MESSAGE_WEBHOOK }}
          title: 'One line message: without quotes'
          status: failure
          message: Hello World!\n\n1. Foo\r2. Bar\n\nEnd
      - name: single-success
        uses: neonidian/teams-notify-build-status@v4
        with:
          webhookUrl: ${{ secrets.TEAMS_MESSAGE_WEBHOOK }}
          title: 'One line message: with quotes'
          status: success
          message: "Hello World!\n\n1. Foo\r2. Bar\n\nEnd"
      - name: multi-fail
        uses: neonidian/teams-notify-build-status@v4
        with:
          webhookUrl: ${{ secrets.TEAMS_MESSAGE_WEBHOOK }}
          title: 'Multi line message: Not enough line breaks!'
          status: failure
          message: >-
            Hello World!
            
            1. Foo
            3. Bar
            
            End.
      - name: multi-success
        uses: neonidian/teams-notify-build-status@v4
        with:
          webhookUrl: ${{ secrets.TEAMS_MESSAGE_WEBHOOK }}
          title: 'Multi line message: Add enough line breaks!'
          status: success
          message: >-
            Hello World!
            
            1. Foo
            
            2. Bar
            
            
            End.

Result:
image

The quotes were important when writing the message in a single line.

When using the multi-line message definition in the workflow file I needed to add one more line break than I would usually do when writing markdown and that's also one more than I would expect based on the documentation about card formats from MS. But that's currently not an issue for me. Therefore I'd close this issue.

Thanks again for your support!

@m-ibot m-ibot closed this as completed Aug 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants