diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d8efaa8..eaa97a5 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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}} diff --git a/emit-log.sh b/emit-log.sh new file mode 100755 index 0000000..11b156f --- /dev/null +++ b/emit-log.sh @@ -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"'"}}' +