Skip to content

Commit 3f43e12

Browse files
committed
feat(ci): Add shell of configure ci environment
1 parent 52c2e02 commit 3f43e12

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tools/ci/configure_ci_environment.sh

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# This file is sourced in to the CI environment
2+
# in .gitlab-ci.yml
3+
#
4+
5+
# Sets the error behaviour options for shell throughout the CI environment
6+
#
7+
set -o errexit # Exit if command failed.
8+
set -o pipefail # Exit if pipe failed.
9+
10+
# we can use the appropriate secret variable for debugging
11+
[ ! -z $DEBUG_SHELL ] && set -x
12+
13+
[ -z $CI_COMMIT_REF_NAME ] && echo "This internal script should only be run by a Gitlab CI runner." && exit 1
14+
15+
# Sets IS_PUBLIC and IS_PRIVATE based on branch type
16+
#
17+
# Public branches are:
18+
# release branches - start with release/
19+
# release tags - look like vXX.YY or vXX.YY.ZZ with an optional dash followed by anything on the end
20+
# master branch
21+
#
22+
# These POSIX REs are equivalent to the REs in some "only:" sections of the gitlab-ci.yml file
23+
#
24+
REF=$CI_COMMIT_REF_NAME
25+
if [[ $REF = "master" || $REF =~ ^release/v || $REF =~ ^v[0-9]+\.[0-9]+(\.[0-9]+)?(-|$) ]]; then
26+
export IS_PRIVATE=
27+
export IS_PUBLIC=1
28+
else
29+
export IS_PRIVATE=1
30+
export IS_PUBLIC=
31+
fi
32+
unset REF

0 commit comments

Comments
 (0)