Skip to content

Commit 70e5f1b

Browse files
cicd: Added checkout to pull the code of the ci-core repository to get the scripts #TASK-8067
1 parent f046887 commit 70e5f1b

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
WORKSPACE=${WORKSPACE:-/home/runner/work/}
3+
4+
5+
function compile() {
6+
local REPO=$1
7+
if [ ! -d "${WORKSPACE}/$REPO" ]; then
8+
echo "Directory ${WORKSPACE}/$REPO does not exist. Skip compile"
9+
return 0;
10+
fi
11+
echo "::group::Compiling '$REPO' project from branch $BRANCH_NAME"
12+
cd "${WORKSPACE}/$REPO" || exit 2
13+
mvn clean install -DskipTests --no-transfer-progress
14+
echo "::endgroup::"
15+
}
16+
17+
## Comma separated list of repos to compile
18+
REPOS=$1
19+
20+
IFS=',' read -ra REPO_ARRAY <<<"$REPOS"
21+
for REPO in "${REPO_ARRAY[@]}"; do
22+
compile "$REPO"
23+
done
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
set -e
3+
set -x
4+
# Function to calculate the corresponding branch of Xetabase project
5+
get_xetabase_branch() {
6+
# Input parameter (branch name)
7+
# Input parameter (branch name)
8+
target_branch="$1"
9+
current_branch="$2"
10+
11+
# If the branch begins with 'TASK' and exists in the opencga-enterprise repository, I return it
12+
if [[ $current_branch == TASK* ]]; then
13+
REPO_URI=
14+
if [ -z "$ZETTA_REPO_ACCESS_TOKEN" ]; then
15+
REPO_URI="git@github.com:zetta-genomics/opencga-enterprise.git"
16+
else
17+
REPO_URI="https://$ZETTA_REPO_ACCESS_TOKEN@github.com/zetta-genomics/opencga-enterprise.git"
18+
fi
19+
if [ "$(git ls-remote "$REPO_URI" "$current_branch" )" ] ; then
20+
echo "$current_branch";
21+
return 0;
22+
fi
23+
fi
24+
25+
# Check if the branch name is "develop" in that case return the same branch name
26+
if [[ "$target_branch" == "develop" ]]; then
27+
echo "develop"
28+
return 0
29+
fi
30+
31+
# Check if the branch name starts with "release-" and follows the patterns "release-a.x.x" or "release-a.b.x"
32+
if [[ "$target_branch" =~ ^release-([0-9]+)\.x\.x$ ]] || [[ "$target_branch" =~ ^release-([0-9]+)\.([0-9]+)\.x$ ]]; then
33+
# Extract the MAJOR part of the branch name
34+
MAJOR=${BASH_REMATCH[1]}
35+
# Calculate the XETABASE_MAJOR by subtracting 3 from MAJOR
36+
XETABASE_MAJOR=$((MAJOR - 3))
37+
# Check if the XETABASE_MAJOR is negative
38+
if (( XETABASE_MAJOR < 0 )); then
39+
echo "Error: 'MAJOR' digit after subtraction results in a negative number."
40+
return 1
41+
fi
42+
# Construct and echo the new branch name
43+
echo "release-$XETABASE_MAJOR.${target_branch#release-$MAJOR.}"
44+
return 0
45+
fi
46+
47+
# If the branch name does not match any of the expected patterns
48+
echo "Error: The branch name is not correct."
49+
return 1
50+
}
51+
52+
# Check if the script receives exactly one argument
53+
if [ "$#" -ne 2 ]; then
54+
echo "Usage: $0 <target-branch> <current-branch>"
55+
exit 1
56+
fi
57+
58+
# Call the function with the input branch name
59+
get_xetabase_branch "$1" "$2"

0 commit comments

Comments
 (0)