forked from Klemensas/chrome-extension-upload-action
-
Notifications
You must be signed in to change notification settings - Fork 4
/
entrypoint.sh
executable file
·58 lines (51 loc) · 951 Bytes
/
entrypoint.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
#!/bin/sh
set -e
token=`curl \
--silent \
--fail \
-H "Content-Type: application/json" \
-d '{
"refresh_token": "'$1'",
"client_id": "'$2'",
"client_secret": "'$3'",
"grant_type": "refresh_token"
}' \
-X POST \
-v https://www.googleapis.com/oauth2/v4/token \
| \
jq -r '.access_token'`
status=`curl \
--silent \
--show-error \
--fail \
-H "Authorization: Bearer $token" \
-H "x-goog-api-version: 2" \
-X PUT \
-T $4 \
-v https://www.googleapis.com/upload/chromewebstore/v1.1/items/$5 \
| \
jq -r '.uploadState'`
if [ $status == 'FAILURE' ]
then
exit 1
fi
if [ $6 == true ] #publish
then
publish=`curl \
--silent \
--show-error \
--fail \
-H "Authorization: Bearer $token" \
-H "x-goog-api-version: 2" \
-X POST \
-T $4 \
-v https://www.googleapis.com/upload/chromewebstore/v1.1/items/$5/publish \
-d publishTarget=default \
| \
jq -r '.publishState'`
if [ $publish == 'FAILURE' ]
then
exit 1
fi
fi
exit 0