Skip to content

Commit bc0afd3

Browse files
author
levy
committed
Merge branch 'dev'
2 parents 914abbe + d87ca9b commit bc0afd3

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

notify.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#!/bin/sh
2+
set -e
3+
4+
echo "checking TRAVIS_TEST_RESULT"
25
if [ "$TRAVIS_TEST_RESULT" != "0" ]
36
then
47
echo "build not success, bye"
@@ -8,11 +11,14 @@ fi
811
ORG_NAME=$(echo "$TRAVIS_REPO_SLUG" | cut -d '/' -f 1)
912
REPO_NAME=$(echo "$TRAVIS_REPO_SLUG" | cut -d '/' -f 2)
1013

14+
echo "pushing commit and tag to github"
1115
git remote add github https://$GITHUB_TOKEN@github.com/$TRAVIS_REPO_SLUG.git > /dev/null 2>&1
1216
git push github HEAD:master --follow-tags
1317

18+
echo "generating github release notes"
1419
GREN_GITHUB_TOKEN=$GITHUB_TOKEN yarn release
1520

21+
echo "downloading github release info"
1622
url=https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/latest
1723
resp_tmp_file=resp.tmp
1824

@@ -22,8 +28,11 @@ html_url=$(sed -n 5p $resp_tmp_file | sed 's/\"html_url\"://g' | awk -F '"' '{pr
2228
body=$(grep body < $resp_tmp_file | sed 's/\"body\"://g;s/\"//g')
2329
version=$(echo $html_url | awk -F '/' '{print $NF}')
2430

31+
echo "notifying with dingtalk bot"
2532
msg='{"msgtype": "markdown", "markdown": {"title": "'$REPO_NAME'更新", "text": "@所有人\n# ['$REPO_NAME'('$version')]('$html_url')\n'$body'"}}'
2633

2734
curl -X POST https://oapi.dingtalk.com/robot/send\?access_token\=$DINGTALK_ROBOT_TOKEN -H 'Content-Type: application/json' -d "$msg"
2835

2936
rm $resp_tmp_file
37+
38+
echo "executing notify.sh successfully"

templates/notify.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
#!/bin/sh
2+
# https://stackoverflow.com/questions/13872048/bash-script-what-does-bin-bash-mean
3+
set -e
4+
5+
echo "1/5: checking TRAVIS_TEST_RESULT"
26
if [ "$TRAVIS_TEST_RESULT" != "0" ]
37
then
48
echo "build not success, bye"
@@ -8,11 +12,14 @@ fi
812
ORG_NAME=$(echo "$TRAVIS_REPO_SLUG" | cut -d '/' -f 1)
913
REPO_NAME=$(echo "$TRAVIS_REPO_SLUG" | cut -d '/' -f 2)
1014

15+
echo "2/5: pushing commit and tag to github"
1116
git remote add github https://$GITHUB_TOKEN@github.com/$TRAVIS_REPO_SLUG.git > /dev/null 2>&1
1217
git push github HEAD:master --follow-tags
1318

19+
echo "3/5: generating github release notes"
1420
GREN_GITHUB_TOKEN=$GITHUB_TOKEN yarn release
1521

22+
echo "4/5: downloading github release info"
1623
url=https://api.github.com/repos/$TRAVIS_REPO_SLUG/releases/latest
1724
resp_tmp_file=resp.tmp
1825

@@ -22,8 +29,11 @@ html_url=$(sed -n 5p $resp_tmp_file | sed 's/\"html_url\"://g' | awk -F '"' '{pr
2229
body=$(grep body < $resp_tmp_file | sed 's/\"body\"://g;s/\"//g')
2330
version=$(echo $html_url | awk -F '/' '{print $NF}')
2431

32+
echo "5/5: notifying with dingtalk bot"
2533
msg='{"msgtype": "markdown", "markdown": {"title": "'$REPO_NAME'更新", "text": "@所有人\n# ['$REPO_NAME'('$version')]('$html_url')\n'$body'"}}'
2634

2735
curl -X POST https://oapi.dingtalk.com/robot/send\?access_token\=$DINGTALK_ROBOT_TOKEN -H 'Content-Type: application/json' -d "$msg"
2836

2937
rm $resp_tmp_file
38+
39+
echo "executing notify.sh successfully"

0 commit comments

Comments
 (0)