forked from awesome-fc/dingtalk-broadcast
-
Notifications
You must be signed in to change notification settings - Fork 0
/
deploy.sh
executable file
·60 lines (46 loc) · 1.69 KB
/
deploy.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
set -e
endpoint=$(cat ~/.fcli/config.yaml | grep 'endpoint' | awk -F ': ' '{print $2}' | sed '2d')
api_version=$(cat ~/.fcli/config.yaml | grep 'api_version' | awk -F '"' '{print $2}')
service_name="dingRobot"-$(date +%s | base64 | sed 's/=/a/g' | sed 's/&/b/g' |head -c 8 )
token=$(date +%s |base64 | sed 's/=/a/g' | sed 's/&/b/g')
trigger_url=$endpoint/$api_version/proxy/$service_name/sendMessage/
rm -rf function
mkdir function
cp urls.txt ./function
cp sendMessage.js ./function
touch ./function/.config
echo "
TOKEN=${token}
ENDPOINT=${trigger_url}
" > ./function/.config
template="ROSTemplateFormatVersion: '2015-09-01'
Transform: 'Aliyun::Serverless-2018-04-03'
Resources:
$service_name: # service name
Type: 'Aliyun::Serverless::Service'
sendMessage: # function name
Type: 'Aliyun::Serverless::Function'
Properties:
Handler: sendMessage.handler #filename
Runtime: nodejs8
CodeUri: './'
Timeout: 60
Events:
httpTrigger: # trigger name
Type: HTTP # http trigger
Properties:
AuthType: ANONYMOUS
Methods: ['GET', 'POST']
"
echo "$template" > ./function/template.yml
cd function
npm add request
npm add raw-body
npm add dotenv
fun deploy > deploy.log
echo '------------------------------------------------------------------------------------------------------------------------------'
echo "| endpoint : $trigger_url"
echo "| token : $token"
echo '------------------------------------------------------------------------------------------------------------------------------'
open "https://awesome-fc.github.io/dingtalk-broadcast/?token=${token}&endpoint=${trigger_url}"