如何在Github操作中将pass env变量作为json的一部分添加?

如何在Github操作中将pass env变量作为json的一部分添加?,json,github-actions,Json,Github Actions,我将以下步骤作为Github工作流的一部分: run: | MESSAGE="${{ env.MESSAGE }}" && echo $MESSAGE \ && curl -X POST -H 'Content-type: application/json' --data '{"text":$MESSAGE}' https://hooks.slack.com/services/<some_ids>

我将以下步骤作为Github工作流的一部分:

run: |
    MESSAGE="${{ env.MESSAGE }}" && echo $MESSAGE \ &&
    curl -X POST -H 'Content-type: application/json' --data '{"text":$MESSAGE}' https://hooks.slack.com/services/<some_ids>

您将变量放在简单引号之间:
--data'{“text”:$MESSAGE}
这会阻止插入
$MESSAGE

您必须将
$MESSAGE
放在双引号之间:
--data“{\”text\”:$MESSAGE}”

--data '{"text":\"$MESSAGE\"}'