#!/bin/sh
# SPDX-License-Identifier: MulanPSL-2.0+
# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.

export server_ip=$SCHED_HOST

git_ci()
{
	# use $GIT_SERVER to direct git remote repo from gitee.com to our own git remote repo(by container git-daemon),
	# to make sure can use the latest code.
	if [ -n "$GIT_SERVER" ]; then
		cat >> /etc/gitconfig <<-EOF
		[url "git://$GIT_SERVER/gitee.com"]
			insteadOf=https://gitee.com
		EOF
	fi

	git clone https://gitee.com/wu_fengguang/compass-ci.git /c/compass-ci || return 1
}

deploy()
{
	cd /c/compass-ci/sparrow && ./install-client
}

git_ci || exit 1
deploy
