action-slack
action-slack copied to clipboard
Newline not interpreted by args?
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.
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.
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"
)