-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgithub.sh
68 lines (56 loc) · 2.01 KB
/
github.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
65
66
67
68
# Report build status next to github commit.
#
# - Fill in USER and APP with your user and appname in appcenter
# - Also provide GITHUB_TOKEN env variable in build config
# (create token in GitHub Settings / Developer Settings / Personal access tokens, with 'repo:status' scope)
#
# Originally written by: Mirosław Zawisza
# https://zeyomir.github.io
#
# The MIT License (MIT)
# Copyright (c) Microsoft Corporation
USER=AtB-AS
build_url=https://appcenter.ms/users/$USER/apps/$APP_NAME/build/branches/$APPCENTER_BRANCH/builds/$BUILD_BUILDID
github_set_status() {
local status job_status
local "${@}"
if [ -z "$APPCENTER_ANDROID_VARIANT" ]; then
tag_name="ios"
else
tag_name="android"
fi
curl -X POST https://api.github.com/repos/$USER/$BUILD_REPOSITORY_NAME/statuses/$BUILD_SOURCEVERSION -d \
"{
\"state\": \"$status\",
\"target_url\": \"$build_url\",
\"description\": \"[BuildID: $APPCENTER_BUILD_ID] The build status is: $job_status!\",
\"context\": \"ci/app-$tag_name\"
}" \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3.raw+json"
}
github_set_status_pending() {
github_set_status status="pending" job_status="In progress"
}
github_set_status_success() {
github_set_status status="success" job_status="$AGENT_JOBSTATUS"
}
github_set_status_fail() {
github_set_status status="failure" job_status="$AGENT_JOBSTATUS"
}
github_set_tag() {
if [ -z "$APPCENTER_ANDROID_VARIANT" ]; then
tag_name="alpha-ios-$APPCENTER_BUILD_ID"
else
tag_name="alpha-android-$APPCENTER_BUILD_ID"
fi
sha=$(git rev-parse $BUILD_SOURCEVERSION^2)
curl -X POST https://api.github.com/repos/$USER/$BUILD_REPOSITORY_NAME/git/refs -d \
"{
\"ref\": \"refs/tags/$tag_name\",
\"sha\": \"$sha\"
}" \
-H "Content-Type: application/json" \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3.raw+json"
}