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:
description: 'DingDing bot token'
required: true
message:
description: 'Message to send'
body:
description: 'Post Body to send'
required: true
runs:

View File

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