2022-03-19 11:49:40 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2022-04-06 19:08:29 +00:00
|
|
|
### returns respective DOCKER TAG
|
|
|
|
### release-tag => <release-tag> (e.g. v1.2.3)
|
|
|
|
### schedule => <SCHEDULE_CADENCE> (e.g. nightly)
|
|
|
|
### master => "master"
|
|
|
|
### else => ""
|
|
|
|
publishdockertag () {
|
2022-04-25 06:10:35 +00:00
|
|
|
# this stores the result in PUBLISH_DOCKER_TAG
|
|
|
|
export PUBLISH_DOCKER_TAG="";
|
2022-04-06 19:08:29 +00:00
|
|
|
if [[ "${CI_COMMIT_TAG}" =~ ${TAG_REGEX} ]]; then
|
2022-04-25 06:10:35 +00:00
|
|
|
export PUBLISH_DOCKER_TAG="${CI_COMMIT_TAG}";
|
2022-03-19 11:49:40 +00:00
|
|
|
return 0;
|
|
|
|
fi
|
2022-04-28 10:03:58 +00:00
|
|
|
if [[ "${SCHEDULE_CADENCE}" != "" && ${CI_PIPELINE_SOURCE} == "schedule" ]]; then
|
2022-04-06 19:08:29 +00:00
|
|
|
# sanitize check
|
|
|
|
if [[ "${SCHEDULE_CADENCE}" =~ ${TAG_REGEX} ]]; then
|
2022-04-25 06:10:35 +00:00
|
|
|
export PUBLISH_DOCKER_TAG="invalid_cadence";
|
2022-04-06 19:08:29 +00:00
|
|
|
else
|
2022-04-25 06:10:35 +00:00
|
|
|
export PUBLISH_DOCKER_TAG="${SCHEDULE_CADENCE}";
|
2022-04-06 19:08:29 +00:00
|
|
|
fi
|
2022-03-19 11:49:40 +00:00
|
|
|
return 0;
|
|
|
|
fi
|
|
|
|
if [[ ${CI_COMMIT_BRANCH} == ${CI_DEFAULT_BRANCH} ]]; then
|
2022-04-25 06:10:35 +00:00
|
|
|
export PUBLISH_DOCKER_TAG="master";
|
2022-03-19 11:49:40 +00:00
|
|
|
return 0;
|
|
|
|
fi
|
|
|
|
}
|