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

deploy()
{
	# redirect remote-repository address to "/srv/git/gitee.com"
	if [ -n "$GIT_SERVER" ]; then
		cat >> /etc/gitconfig <<-EOF
		[url "git://$GIT_SERVER/gitee.com"]
			insteadOf=https://gitee.com
		EOF
	fi

	mkdir -p /c && cd /c
	git clone https://gitee.com/wu_fengguang/compass-ci.git

	cd /c/compass-ci || exit
	[ -n "$compass_commit_id" ] && git reset --hard "$compass_commit_id"

	# Need mount tmpfs to fix compass-ci/container/os-nfs/start error
	# "exportfs: /exports/result does not support NFS export"
	mount -t tmpfs none /srv

	# test the script for one-click deployment
	cd /c/compass-ci/sparrow || exit
	prepare_testboxes=false ./install-tiny
}

deploy
