forked from openhab/openhabian
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ci-setup.bash
executable file
·38 lines (34 loc) · 1.27 KB
/
ci-setup.bash
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
#!/usr/bin/env bash
##########################
#### Load help method ####
##########################
# shellcheck disable=SC1090
source functions/helpers.bash
## This function formats log messages
##
## echo_process(String message)
##
echo_process() {
echo -e "${COL_CYAN}$(timestamp) [openHABian] ${*}${COL_DEF}"
}
if [[ $1 == "github" ]]; then
repoURL="$(git remote get-url origin)"
repoBranch="$(git rev-parse --abbrev-ref HEAD)"
sed -i 's#debugmode=.*$#debugmode=on#' build-image/openhabian.conf
if ! [[ $repoURL == "https"* ]]; then
# Convert URL from SSH to HTTPS
username="$(echo "$repoURL" | sed -Ene's#git@github.com:([^/]*)/(.*).git#\1#p')"
if [[ -z $username ]]; then
echo_process "Could not identify git user while converting to SSH URL. Exiting."
exit 1
fi
reponame="$(echo "$repoURL" | sed -Ene's#git@github.com:([^/]*)/(.*).git#\2#p')"
if [[ -z $reponame ]]; then
echo_process "Could not identify git repo while converting to SSH URL. Exiting."
exit 1
fi
repoURL="https://github.com/${username}/${reponame}.git"
fi
sed -i 's|repositoryurl=.*$|repositoryurl='"${repoURL}"'|' build-image/openhabian"${2}".conf
sed -i 's|clonebranch=.*$|clonebranch='"${repoBranch}"'|' build-image/openhabian"${2}".conf
fi