-
Notifications
You must be signed in to change notification settings - Fork 0
/
update-status.sh
executable file
·64 lines (57 loc) · 1.38 KB
/
update-status.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
#!/bin/bash
set -e
# Usage: ./update-status.sh --sha=somesha \
# --repo=edyn/service-identity \
# --status=pending \
# --message="Starting tests" \
# --context=edyn/e2e \
# --url=http://something.com
#
STATUS=${STATUS:-"pending"}
REPO_SLUG=${REPO_SLUG:-}
BUILD_URL=${BUILD_URL:-}
for i in "$@"
do
case $i in
-s=*|--sha=*)
COMMIT_SHA="${i#*=}"
shift # past argument=value
;;
-r=*|--repo=*)
REPO_SLUG="${i#*=}"
shift # past argument=value
;;
-m=*|--message=*)
CHECK_MESSAGE="${i#*=}"
shift # past argument=value
;;
-u=*|--url=*)
BUILD_URL="${i#*=}"
shift # past argument=value
;;
--status=*)
STATUS="${i#*=}"
shift # past argument=value
;;
-c=*|--context)
CHECK_CONTEXT="${i#*=}"
shift # past argument with no value
;;
*)
# unknown option
;;
esac
done
echo "COMMIT_SHA = ${COMMIT_SHA}"
echo "REPO_SLUG = ${REPO_SLUG}"
echo "STATUS = ${STATUS}"
echo "CHECK_CONTEXT = ${CHECK_CONTEXT}"
echo "BUILD_URL = ${BUILD_URL}"
echo "CHECK_MESSAGE = ${CHECK_MESSAGE}"
echo $CHECK_MESSAGE
set -x
curl -u $GITHUB_USER_TOKEN \
--header "Content-Type: application/json" \
--data '{"state": "'$STATUS'", "context": "'$CHECK_CONTEXT'", "description": "'"$CHECK_MESSAGE"'", "target_url": "'$BUILD_URL'"}' \
--request POST \
https://api.github.com/repos/$REPO_SLUG/statuses/$COMMIT_SHA