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\"}'
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}"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.