forked from redhat-appstudio/tssc-dev-multi-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup-local-dev-repos.sh
executable file
·67 lines (58 loc) · 2.57 KB
/
setup-local-dev-repos.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
echo "Configure the repos for Innerloop dev"
TEST_REPO_ORG="${MY_TEST_REPO_ORG:-redhat-appstudio}"
TEST_REPO_GITLAB_ORG="${MY_TEST_REPO_GITLAB_ORG:-redhat-appstudio}"
if [ $TEST_REPO_ORG == "redhat-appstudio" ]; then
echo "Build can use redhat-appstudio directly, gitops needs a forked repo."
echo "Set up a github and gitlab fork in github and gitlab "
echo "Pass org names in MY_TEST_REPO_ORG and MY_TEST_REPO_GITLAB_ORG"
fi
if [ $TEST_REPO_GITLAB_ORG == "redhat-appstudio" ]; then
echo "WARNING: Gitops may not use redhat-appstudio, gitops needs a forked repo."
echo "Set up a github and gitlab fork in github and gitlab "
echo "Pass org names in MY_TEST_REPO_ORG and MY_TEST_REPO_GITLAB_ORG"
fi
# this will be copied into a temp directory
# pipelines will be pushed into it for local test
# build and gitops on gitlab
TEST_BUILD_REPO=https://github.com/$TEST_REPO_ORG/devfile-sample-nodejs-dance
# These repos are all optional, if they don't exist, the build can continue
TEST_GITOPS_REPO=https://github.com/$TEST_REPO_ORG/tssc-dev-gitops
TEST_BUILD_GITLAB_REPO=https://gitlab.com/$TEST_REPO_GITLAB_ORG/devfile-sample-nodejs-dance
TEST_GITOPS_GITLAB_REPO=https://gitlab.com/$TEST_REPO_GITLAB_ORG/tssc-dev-gitops
function cloneIfRepoExists() {
REPO=$1
DEST=$2
echo "Test repo $repo and clone into $DEST"
REPO_EXISTS=$(curl -s -o /dev/null -I -w "%{http_code}" $REPO)
# 200 == exists
# 404 == does not exist
if [ $REPO_EXISTS == 200 ]; then
echo "Clone source: $REPO into : $DEST"
git clone --quiet $REPO $DEST > /dev/null
else
echo "Cannot find $REPO - skipping it"
fi
}
# clone if repos exist, disable gitops
# Github in build/gitops
# Gitlab in gitlab-build, gitlab-gitops
TMP_REPOS=tmp
rm -rf $TMP_REPOS/*
BUILD=$TMP_REPOS/build
GITOPS=$TMP_REPOS/gitops
GITLAB_BUILD=$TMP_REPOS/gitlab-build
GITLAB_GITOPS=$TMP_REPOS/gitlab-gitops
cloneIfRepoExists $TEST_BUILD_REPO $BUILD
cloneIfRepoExists $TEST_GITOPS_REPO $GITOPS
cloneIfRepoExists $TEST_BUILD_GITLAB_REPO $GITLAB_BUILD
cloneIfRepoExists $TEST_GITOPS_GITLAB_REPO $GITLAB_GITOPS
# WARNING - if GITOPS_REPO_URL is set, update deployment will try to update
# the gitops repo. Disable this here if the gitops repo is NOT a fork
if [ $TEST_REPO_ORG == "redhat-appstudio" ]; then
echo "------------- INFO-------------"
echo "DISABLING GITOPS REPO UPDATE for the "redhat-appstudio" org"
echo "This prevents random accidental updates to the shared repo by dev team members with access"
export DISABLE_GITOPS_UPDATE=true
echo "^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^"
echo
fi