Skip to content

Convert the line breaks to Slack \n #8

@denis-trofimov

Description

@denis-trofimov

Then I pass output of Run LoveToKnow/slackify-markdown-action@v1.0.0 to the slackapi/slack-github-action@v1.24.0, I can have error "passed in payload was invalid JSON".

I think Slack is breaking on '%0A', expecting text "\n".

Line breaks
You can use multi-line text in app-generated text. Insert a newline by including the string \n in your text. For example:
This is a line of text.\nAnd this is another one.

Example text input should be any line break containing.

##[debug]..Evaluating String:
##[debug]..=> 'message'
##[debug]=> '**Your Huma server API is ready to use.✅**
##[debug]
##[debug]Huma server API links:
##[debug]

::set-output name=text::​*Your Huma server API is ready to use.✅*​%0A%0AHuma server API links:%0A

My part of Github workflow:

    - id: convertTextSlackReady
      if: steps.install.outputs.error == 0 &&  steps.restore.outputs.error == 0
      uses: LoveToKnow/slackify-markdown-action@v1.0.0
      with:
        text: ${{ steps.readyMessage.outputs.message }}

    - name: Slack links list
      if: steps.install.outputs.error == 0 &&  steps.restore.outputs.error == 0
      uses: slackapi/slack-github-action@v1.24.0
      with:
        channel-id: ${{ inputs.slack_channel_id }}
        payload: |
          {
            "text": "Your server API is ready to use.",
            "blocks": [
              {
                "type": "section",
                "text": {
                  "type": "mrkdwn",
                  "text": "${{ steps.convertTextSlackReady.outputs.text }}"
                }
              }
            ]
          }
      env:
        SLACK_BOT_TOKEN: ${{ inputs.slack_bot_token }}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions