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

Convert the line breaks to Slack \n #8

Open
denis-trofimov opened this issue May 24, 2023 · 0 comments
Open

Convert the line breaks to Slack \n #8

denis-trofimov opened this issue May 24, 2023 · 0 comments

Comments

@denis-trofimov
Copy link
Contributor

denis-trofimov commented May 24, 2023

Then I pass output of Run LoveToKnow/[email protected] to the slackapi/[email protected], 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/[email protected]
      with:
        text: ${{ steps.readyMessage.outputs.message }}

    - name: Slack links list
      if: steps.install.outputs.error == 0 &&  steps.restore.outputs.error == 0
      uses: slackapi/[email protected]
      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 }}
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

Successfully merging a pull request may close this issue.

1 participant