more flexiable

This commit is contained in:
zcong1993 2019-08-29 16:48:20 +08:00
parent 65e38d7faa
commit 73fed0e15e
2 changed files with 7 additions and 15 deletions

View File

@ -8,8 +8,8 @@ inputs:
dingToken: dingToken:
description: 'DingDing bot token' description: 'DingDing bot token'
required: true required: true
message: body:
description: 'Message to send' description: 'Post Body to send'
required: true required: true
runs: runs:

View File

@ -6,24 +6,16 @@ then
exit 1 exit 1
fi fi
if [ -z "${INPUT_MESSAGE}" ] if [ -z "${INPUT_BODY}" ]
then then
echo "message is required!" echo "body is required!"
exit 1 exit 1
fi fi
url="https://oapi.dingtalk.com/robot/send?access_token=${INPUT_DINGTOKEN}" echo "body: $INPUT_BODY"
body=$(cat <<EOF url="https://oapi.dingtalk.com/robot/send?access_token=${INPUT_DINGTOKEN}"
{
"msgtype": "text",
"text": {
"content": "${INPUT_MESSAGE}"
}
}
EOF
)
curl "$url" \ curl "$url" \
-H 'Content-Type: application/json' \ -H 'Content-Type: application/json' \
-d "${body}" -d "${INPUT_BODY}"