Skip to content

Commit

Permalink
chore: 发送消息配置
Browse files Browse the repository at this point in the history
  • Loading branch information
wang.kangning committed Sep 4, 2023
1 parent d48d32b commit 6c6f17c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
7 changes: 6 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,12 @@ jobs:
npm i pnpm -g
pnpm i --no-frozen-lockfile
- name: publish
run: npm run pub:only
run: npm run pub:only | tee log.txt
env:
NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
NPM_TOKEN: ${{secrets.NPM_TOKEN}}
- name: emit log
if: always()
run: ./emit-log.sh
env:
DING_TOKEN: ${{secrets.DING_TOKEN}}
19 changes: 19 additions & 0 deletions emit-log.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash

# 取出 log.txt 的文件内容
log=$(cat log.txt|grep 'New tag:')

# 如果 log.txt 为空
if [ -z "$log" ]; then
curl 'https://oapi.dingtalk.com/robot/send?access_token=${DING_TOKEN}' \
-H 'Content-Type: application/json' \
-d '{"msgtype": "markdown","markdown": {"title":"orca-fe发布通知","text":"### @orca-fe/vite-plugins\n流水线结束,没有新的模块发布"}}'
exit 0
fi

# 如果 log.txt 不为空,则将 log 作为消息发出去,需要将 log 的换行符替换为 \n
log=${log//$'\n'/\\n}
curl 'https://oapi.dingtalk.com/robot/send?access_token=${DING_TOKEN}' \
-H 'Content-Type: application/json' \
-d '{"msgtype": "markdown","markdown": {"title":"orca-fe发布通知","text":"### @orca-fe/vite-plugins\n流水线结束,以下模块已发布:\n'"$log"'"}}'

0 comments on commit 6c6f17c

Please sign in to comment.