Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e7c2f2cc05 | |||
| 2a68a4d06e | |||
| 5cf291c851 | |||
| dbf39fd4a7 | |||
| 6795ef8f80 |
@@ -0,0 +1,27 @@
|
||||
name: Test
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
# test action works running from the graph
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Send dingding notify
|
||||
uses: ./
|
||||
with:
|
||||
dingToken: ${{ secrets.DING_TOKEN }}
|
||||
secret: ${{ secrets.DING_SECRET }} # if secret set, action will call API with sign
|
||||
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"
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,17 @@
|
||||
|
||||
Send dingding simple notify message.
|
||||
|
||||
## Usage
|
||||
|
||||
| option | required | description |
|
||||
| ----------- | -------- | ------------------------------------------------------------------------------------------------------------------- |
|
||||
| dingToken | true | DingDing bot access_token |
|
||||
| body | true | any kind of message body [dingding](https://ding-doc.dingtalk.com/doc#/serverapi2/qf2nxq) support into `body` field |
|
||||
| secret | false | if secret set, action will call API with sign |
|
||||
| ignoreError | false | if set true, will not fail action when API call failed |
|
||||
|
||||
## Examples
|
||||
|
||||
```yaml
|
||||
- name: Send dingding notify
|
||||
uses: zcong1993/actions-ding@master
|
||||
@@ -19,7 +30,7 @@ Send dingding simple notify message.
|
||||
}
|
||||
```
|
||||
|
||||
## sign
|
||||
### with sign
|
||||
|
||||
```yaml
|
||||
- name: Send dingding notify
|
||||
|
||||
@@ -14,6 +14,9 @@ inputs:
|
||||
secret:
|
||||
description: 'If use sign secret'
|
||||
required: false
|
||||
ignoreError:
|
||||
description: 'If set true, will not fail action when API call failed'
|
||||
required: false
|
||||
|
||||
runs:
|
||||
using: 'node12'
|
||||
|
||||
Vendored
+4895
-2822
File diff suppressed because it is too large
Load Diff
+14
-14
@@ -8,9 +8,9 @@
|
||||
"format": "prettier --write **/*.ts",
|
||||
"format-check": "prettier --check **/*.ts",
|
||||
"lint": "eslint src/**/*.ts",
|
||||
"pack": "ncc build src/index.ts -o dist",
|
||||
"package": "ncc build src/index.ts -o dist",
|
||||
"test": "jest",
|
||||
"all": "npm run build && npm run format && npm run lint && npm run pack && npm test"
|
||||
"all": "npm run build && npm run format && npm run lint && npm run package && npm test"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
@@ -24,19 +24,19 @@
|
||||
"author": "zcong1993",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"@actions/core": "^1.2.4",
|
||||
"@zcong/ding-bot": "^0.1.0"
|
||||
"@actions/core": "^1.6.0",
|
||||
"@zcong/ding-bot": "^0.1.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/jest": "^26.0.0",
|
||||
"@types/node": "^14.0.13",
|
||||
"@typescript-eslint/parser": "^3.3.0",
|
||||
"@zeit/ncc": "^0.22.3",
|
||||
"eslint": "^7.2.0",
|
||||
"eslint-plugin-github": "^4.0.1",
|
||||
"eslint-plugin-jest": "^23.13.2",
|
||||
"jest": "^26.0.1",
|
||||
"prettier": "^2.0.5",
|
||||
"typescript": "^3.9.5"
|
||||
"@types/jest": "^27.0.2",
|
||||
"@types/node": "^16.11.6",
|
||||
"@typescript-eslint/parser": "^5.3.0",
|
||||
"@vercel/ncc": "^0.31.1",
|
||||
"eslint": "^8.2.0",
|
||||
"eslint-plugin-github": "^4.3.3",
|
||||
"eslint-plugin-jest": "^25.2.3",
|
||||
"jest": "^27.3.1",
|
||||
"prettier": "^2.4.1",
|
||||
"typescript": "^4.4.4"
|
||||
}
|
||||
}
|
||||
|
||||
Generated
+3322
-6880
File diff suppressed because it is too large
Load Diff
+16
-6
@@ -8,8 +8,8 @@ async function run(): Promise<void> {
|
||||
const token = core.getInput('dingToken')
|
||||
const body = core.getInput('body')
|
||||
const secretStr = core.getInput('secret')
|
||||
const ignoreError = core.getInput('ignoreError') === 'true'
|
||||
const secret = secretStr === '' ? undefined : secretStr
|
||||
const data = JSON.parse(body)
|
||||
if (secret) {
|
||||
core.info('get secret, sign mode')
|
||||
}
|
||||
@@ -21,18 +21,28 @@ async function run(): Promise<void> {
|
||||
})
|
||||
|
||||
try {
|
||||
const resp = await dingBot.rawSend(data)
|
||||
const resp = await dingBot.rawSend(body)
|
||||
|
||||
if (resp?.errcode !== 0) {
|
||||
core.setFailed(resp?.errmsg)
|
||||
if (ignoreError) {
|
||||
core.warning(resp?.errmsg)
|
||||
return
|
||||
} else {
|
||||
core.setFailed(resp?.errmsg)
|
||||
}
|
||||
}
|
||||
} catch (requestErr) {
|
||||
} catch (requestErr: any) {
|
||||
core.error(
|
||||
`send request error, status: ${requestErr.response?.status}, data: ${requestErr.response?.data}`
|
||||
)
|
||||
core.setFailed(requestErr.message)
|
||||
if (ignoreError) {
|
||||
core.warning(requestErr.message)
|
||||
return
|
||||
} else {
|
||||
core.setFailed(requestErr.message)
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
} catch (error: any) {
|
||||
core.setFailed(error.message)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user