commit
335cfef34c
|
@ -0,0 +1,12 @@
|
||||||
|
root = true
|
||||||
|
|
||||||
|
[*]
|
||||||
|
indent_style = space
|
||||||
|
indent_size = 2
|
||||||
|
end_of_line = lf
|
||||||
|
charset = utf-8
|
||||||
|
trim_trailing_whitespace = true
|
||||||
|
insert_final_newline = true
|
||||||
|
|
||||||
|
[*.md]
|
||||||
|
trim_trailing_whitespace = false
|
13
README.md
13
README.md
|
@ -7,5 +7,16 @@ Send dingding simple notify message.
|
||||||
uses: zcong1993/actions-ding@master
|
uses: zcong1993/actions-ding@master
|
||||||
with:
|
with:
|
||||||
dingToken: ${{ secrets.DING_TOKEN }}
|
dingToken: ${{ secrets.DING_TOKEN }}
|
||||||
message: test message
|
body: |
|
||||||
|
{
|
||||||
|
"msgtype": "link",
|
||||||
|
"link": {
|
||||||
|
"text": "这个即将发布的新版本,创始人陈航(花名“无招”)称它为“红树林”。而在此之前,每当面临重大升级,产品经理们都会取一个应景的代号,这一次,为什么是“红树林”?",
|
||||||
|
"title": "时代的火车向前开",
|
||||||
|
"picUrl": "",
|
||||||
|
"messageUrl": "https://www.dingtalk.com/s?__biz=MzA4NjMwMTA2Ng==&mid=2650316842&idx=1&sn=60da3ea2b29f1dcc43a7c8e4a7c97a16&scene=2&srcid=09189AnRJEdIiWVaKltFzNTw&from=timeline&isappinstalled=0&key=&ascene=2&uin=&devicetype=android-23&version=26031933&nettype=WIFI"
|
||||||
|
}
|
||||||
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
put any kind of message body [dingding](https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq) support into `body` field.
|
||||||
|
|
|
@ -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:
|
||||||
|
|
|
@ -6,24 +6,24 @@ 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
|
||||||
|
|
||||||
|
echo "body: $INPUT_BODY"
|
||||||
|
|
||||||
url="https://oapi.dingtalk.com/robot/send?access_token=${INPUT_DINGTOKEN}"
|
url="https://oapi.dingtalk.com/robot/send?access_token=${INPUT_DINGTOKEN}"
|
||||||
|
|
||||||
body=$(cat <<EOF
|
HTTP_RESPONSE=$(curl -s --write-out "HTTPSTATUS:%{http_code}" "$url" \
|
||||||
{
|
|
||||||
"msgtype": "text",
|
|
||||||
"text": {
|
|
||||||
"content": "${INPUT_MESSAGE}"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
)
|
|
||||||
|
|
||||||
curl "$url" \
|
|
||||||
-H 'Content-Type: application/json' \
|
-H 'Content-Type: application/json' \
|
||||||
-d "${body}"
|
-d "${INPUT_BODY}")
|
||||||
|
|
||||||
|
# extract the body
|
||||||
|
HTTP_BODY=$(echo "$HTTP_RESPONSE" | sed -e 's/HTTPSTATUS\:.*//g')
|
||||||
|
|
||||||
|
if [ ! "$HTTP_BODY" = '{"errcode":0,"errmsg":"ok"}' ]; then
|
||||||
|
echo "Error Response: ${HTTP_RESPONSE}"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
Loading…
Reference in New Issue