Skip to content

Commit

Permalink
chore: update publish config
Browse files Browse the repository at this point in the history
  • Loading branch information
NicoKam committed Sep 4, 2023
1 parent da0306c commit 16eddd2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
8 changes: 7 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@ jobs:
npm i pnpm -g
pnpm i --no-frozen-lockfile
- name: publish
run: npm run pub:only > publish_log.txt
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/pocket\n\n流水线结束,没有新的模块发布"}}'
exit 0
fi

# 如果 log.txt 不为空,则将 log 作为消息发出去,需要将 log 的换行符替换为 \n\n
log=$(echo "$log"|sed 's/\n/\\n\\n/g')
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/pocket\n\n流水线结束,以下模块已发布:\n\n'"$log"'"}}'

0 comments on commit 16eddd2

Please sign in to comment.