action-slack icon indicating copy to clipboard operation
action-slack copied to clipboard

Newline not interpreted by args?

Open melchoir55 opened this issue 4 years ago β€’ 2 comments

We're having a weird issue where env vars are interpolating but we can't seem to get a newline character to work. We've tried both single and double character escapes:

      - name: Slack notification
        env:
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
        uses: Ilshidur/[email protected]
        with:
          args: 'A merge to `App.dev` has occurred successfully. \\n
          Commit ID: {{GITHUB_SHA}} \\n'
      - name: Slack notification
        env:
          SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
        uses: Ilshidur/[email protected]
        with:
          args: 'A merge to `App.dev` has occurred successfully. \n
          Commit ID: {{GITHUB_SHA}} \n'

For some reason the \n or \\n just show up directly in the message without being interpreted. Could you please offer some guidance here? Also great job on the rest of your documentation. Very easy to understand.

melchoir55 avatar Oct 30 '20 21:10 melchoir55

We got this working by changing the single quote to double quote on the string parameter passed to args. I think it would be worth updating your docs with this bit.

melchoir55 avatar Oct 30 '20 22:10 melchoir55

Use double quotes. ☺️ here is the args for my beloved bot Illidan Stormrage:

with:
  args: "*BUILD failed*\n_You are not prepared._"

It's needed to investigate further ahead why it's necessary, and how far that 'real' line break you added after the \n is maybe affecting anything. and maybe a PR tweak it so people also don't fall in this pit.

a guess is maybe the double quote tells the YAML parser interpolate that line.. (like in the command line behaviour, e.g: echo 'I am $USER' versus: echo "I am $USER")

itsmelion avatar Nov 12 '20 19:11 itsmelion