parent
99a9cd34d2
commit
118df2942e
1 changed files with 28 additions and 15 deletions
43
cd.sh
43
cd.sh
|
@ -6,7 +6,10 @@ CD_DNS_SERVERS=(
|
|||
CD_NAME='cd'
|
||||
CD_REPOSITORIES_PARENT='rwx'
|
||||
|
||||
CD_DNS_FILE='/etc/resolv.conf'
|
||||
function cd_set_environment {
|
||||
#
|
||||
CD_DNS_FILE='/etc/resolv.conf'
|
||||
CD_ENV="$(mktemp)"
|
||||
case "${CD_OS_NAME}" in
|
||||
'debian')
|
||||
CD_PYTHON_COMMAND='python3'
|
||||
|
@ -29,9 +32,7 @@ esac
|
|||
# project / branch
|
||||
[ "${CI_COMMIT_BRANCH}" ] && export CD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
|
||||
[ "${GITHUB_REF_NAME}" ] && export CD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
|
||||
if [ "${CD_PROJECT_BRANCH}" ] ; then
|
||||
echo "CD_PROJECT_BRANCH = ${CD_PROJECT_BRANCH}"
|
||||
else
|
||||
if [ ! "${CD_PROJECT_BRANCH}" ] ; then
|
||||
echo 'CD_PROJECT_BRANCH'
|
||||
exit 3
|
||||
fi
|
||||
|
@ -40,9 +41,7 @@ fi
|
|||
&& CD_PROJECT_NAME="$(basename "${CI_PROJECT_PATH}")"
|
||||
[ "${GITHUB_REPOSITORY}" ] \
|
||||
&& CD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
|
||||
if [ "${CD_PROJECT_NAME}" ] ; then
|
||||
echo "CD_PROJECT_NAME = ${CD_PROJECT_NAME}"
|
||||
else
|
||||
if [ ! "${CD_PROJECT_NAME}" ] ; then
|
||||
echo 'CD_PROJECT_NAME'
|
||||
exit 3
|
||||
fi
|
||||
|
@ -51,9 +50,7 @@ fi
|
|||
&& CD_PROJECTS_GROUP="$(dirname "${CI_PROJECT_PATH}")"
|
||||
[ "${GITHUB_REPOSITORY}" ] \
|
||||
&& CD_PROJECTS_GROUP="$(dirname "${GITHUB_REPOSITORY}")"
|
||||
if [ "${CD_PROJECTS_GROUP}" ] ; then
|
||||
echo "CD_PROJECTS_GROUP = ${CD_PROJECTS_GROUP}"
|
||||
else
|
||||
if [ ! "${CD_PROJECTS_GROUP}" ] ; then
|
||||
echo 'CD_PROJECTS_GROUP'
|
||||
exit 3
|
||||
fi
|
||||
|
@ -62,14 +59,28 @@ fi
|
|||
[ "${GITHUB_SERVER_URL}" ] && CD_PROJECTS_URL="${GITHUB_SERVER_URL}"
|
||||
if [ "${CD_PROJECTS_URL}" ] ; then
|
||||
CD_PROJECTS_URL+="/${CD_PROJECTS_GROUP}"
|
||||
echo "CD_PROJECTS_URL = ${CD_PROJECTS_URL}"
|
||||
else
|
||||
echo 'CD_PROJECTS_URL'
|
||||
exit 3
|
||||
fi
|
||||
# project / url
|
||||
CD_PROJECT_URL="${CD_PROJECTS_URL}/${CD_PROJECT_NAME}"
|
||||
echo "CD_PROJECT_URL = ${CD_PROJECT_URL}"
|
||||
# project / url
|
||||
CD_PROJECT_URL="${CD_PROJECTS_URL}/${CD_PROJECT_NAME}"
|
||||
}
|
||||
|
||||
function cd_write_environment {
|
||||
cd_write "${CD_ENV}" "{
|
||||
\"project\": {
|
||||
\"branch\": \"${CD_PROJECT_BRANCH}\",
|
||||
\"name\": \"${CD_PROJECT_NAME}\",
|
||||
\"url\": \"${CD_PROJECT_URL}\"
|
||||
},
|
||||
\"projects\": {
|
||||
\"group\": \"${CD_PROJECTS_GROUP}\",
|
||||
\"url\": \"${CD_PROJECTS_URL}\"
|
||||
}
|
||||
}"
|
||||
cat "${CD_ENV}"
|
||||
}
|
||||
|
||||
function cd_step {
|
||||
if [ "${1}" ] ; then
|
||||
|
@ -239,10 +250,12 @@ local root
|
|||
|
||||
function cd_bootstrap {
|
||||
cd_step "${FUNCNAME}"
|
||||
"${CD_PYTHON_COMMAND}" -m "${CD_NAME}"
|
||||
"${CD_PYTHON_COMMAND}" -m "${CD_NAME}" "${CD_ENV}"
|
||||
}
|
||||
|
||||
function cd_main {
|
||||
cd_set_environment
|
||||
cd_write_environment
|
||||
cd_set_dns_resolving
|
||||
cd_set_packages_repositories
|
||||
cd_set_packages_configuration
|
||||
|
|
Loading…
Reference in a new issue