-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathentrypoint.sh
executable file
·64 lines (55 loc) · 1.13 KB
/
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
59
60
61
62
63
64
#!/usr/bin/env bash
COLOR=$1
SHOW_YEAR=$2
SHOW_MONTH=$3
SHOW_DAY=$4
SHOW_HOUR=$5
GIST_ID=$6
GIST_TOKEN=$7
GIST_FILENAME=$8
DATE_STRING=""
if [ "$SHOW_YEAR" == "true" ]; then
DATE_STRING+=$(date -u +"%Y")
fi
if [ "$SHOW_MONTH" == "true" ]; then
if [ -n "$DATE_STRING" ]; then
DATE_STRING+=" "
fi
DATE_STRING+=$(date -u +"%b")
fi
if [ "$SHOW_DAY" == "true" ]; then
if [ -n "$DATE_STRING" ]; then
DATE_STRING+=" "
fi
DATE_STRING+=$(date -u +"%d")
fi
if [ "$SHOW_HOUR" == "true" ]; then
if [ -n "$DATE_STRING" ]; then
DATE_STRING+=" "
fi
DATE_STRING+=$(date -u +"%r %Z")
fi
JSON_CONTENT=$(jq -n \
--arg label "Last CI" \
--arg message "$DATE_STRING" \
--arg color "$COLOR" \
'{
"schemaVersion": 1,
"label": $label,
"message": $message,
"color": $color
}')
JSON_PAYLOAD=$(jq -n \
--arg filename "$GIST_FILENAME" \
--arg content "$JSON_CONTENT" \
'{
"files": {
($filename): {
"content": $content
}
}
}')
curl -X PATCH "https://api.github.com/gists/$GIST_ID" \
-H "Authorization: token $GIST_TOKEN" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD"