-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sh
executable file
·43 lines (28 loc) · 1.09 KB
/
build.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
#!/usr/bin/env bash
# Script for cronjob, will open an issue on cdnjs/cdnjs if build failed.
StartTimestamp="$(date +%s)"
pth="$(dirname "$(readlink -f "$0")")"
cat "$pth/banner"
. "$pth/config.sh"
export PATH="$path:$PATH"
if [ "$(uname)" = "FreeBSD" ] || [ "$(uname)" = "Darwin" ]; then
sed="gsed"
else
sed="sed"
fi
apiUrl='https://api.github.com/repos/cdnjs/cdnjs/issues'
IssueTitle="[Build failed] Got error while building meta data/artifact"
IssueAssignee="robocdnjs"
IssueLabels='["Bug - High Priority"]'
IssueContent="$($sed ':a;N;$!ba;s/\n/\\n/g' "$pth/issueTemplate")"
Issue="{ \"title\": \"$IssueTitle\", \"body\": \"$IssueContent\", \"assignee\": \"$IssueAssignee\", \"labels\": $IssueLabels }"
flock -E 87 -n build.lock -c "$pth/update-website.sh build"
error=$?
if [ $error -eq 87 ]; then
echo -e "\\nPrevious build locked!\\n"
elif [ $error -ne 0 ]; then
curl --silent -H "Authorization: token $githubToken" -d "$Issue" "$apiUrl" > /dev/null
fi
EndTimestamp="$(date +%s)"
echo -e "\\nTotal time spent for this build is _$((EndTimestamp - StartTimestamp))_ second(s)\\n"
exit $error