Reputation: 89
I have the following steps as part of a Github Workflow:
run: |
MESSAGE="${{ env.MESSAGE }}" && echo $MESSAGE \ &&
curl -X POST -H 'Content-type: application/json' --data '{"text":$MESSAGE}' https://hooks.slack.com/services/<some_ids>
The echo works and outputs the correct message, but replacing the message in the json fails. What is the correct syntax?
I already tried escaping the quotes (it's not valid syntax):
--data '{"text":\"$MESSAGE\"}'
Upvotes: 1
Views: 4013
Reputation: 1050
you are putting your variable between simple quotes : --data '{"text":$MESSAGE}'
which prevents interpolation of $MESSAGE
.
you have to put $MESSAGE
between double quotes: --data "{\"text\": $MESSAGE}"
Upvotes: 4