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 () {
|
|
|
|
# this stores the result in a variable defined by the caller
|
2022-03-19 11:49:40 +00:00
|
|
|
local -n VAR=$1
|
2022-04-06 19:08:29 +00:00
|
|
|
VAR="";
|
|
|
|
if [[ "${CI_COMMIT_TAG}" =~ ${TAG_REGEX} ]]; then
|
|
|
|
VAR="${CI_COMMIT_TAG}";
|
2022-03-19 11:49:40 +00:00
|
|
|
return 0;
|
|
|
|
fi
|
|
|
|
if [[ -z "${SCHEDULE_CADENCE}" && ${CI_PIPELINE_SOURCE} == "schedule" ]]; then
|
2022-04-06 19:08:29 +00:00
|
|
|
# sanitize check
|
|
|
|
if [[ "${SCHEDULE_CADENCE}" =~ ${TAG_REGEX} ]]; then
|
|
|
|
VAR="invalid_cadence";
|
|
|
|
else
|
|
|
|
VAR="${SCHEDULE_CADENCE}";
|
|
|
|
fi
|
2022-03-19 11:49:40 +00:00
|
|
|
return 0;
|
|
|
|
fi
|
|
|
|
if [[ ${CI_COMMIT_BRANCH} == ${CI_DEFAULT_BRANCH} ]]; then
|
|
|
|
VAR="master";
|
|
|
|
return 0;
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
### returns respective GIT TAG
|
2022-04-06 19:08:29 +00:00
|
|
|
### release-tag => "" (releases already have a tag)
|
|
|
|
### schedule => <SCHEDULE_CADENCE> (e.g. nightly)
|
|
|
|
### master => "" (master doesn't need a tag)
|
|
|
|
### else => ""
|
2022-03-19 11:49:40 +00:00
|
|
|
publishgittag () {
|
|
|
|
local -n VAR=$1
|
2022-04-06 19:08:29 +00:00
|
|
|
if [[ -z "${SCHEDULE_CADENCE}" && ${CI_PIPELINE_SOURCE} == "schedule" ]]; then
|
2022-03-19 11:49:40 +00:00
|
|
|
VAR="${SCHEDULE_CADENCE}";
|
2022-04-06 19:08:29 +00:00
|
|
|
# sanitize check
|
|
|
|
if [[ "${SCHEDULE_CADENCE}" =~ ${TAG_REGEX} ]]; then
|
|
|
|
VAR="invalid_cadence";
|
|
|
|
else
|
|
|
|
VAR="${SCHEDULE_CADENCE}";
|
|
|
|
fi
|
2022-03-19 11:49:40 +00:00
|
|
|
return 0;
|
|
|
|
fi
|
|
|
|
VAR="";
|
|
|
|
}
|