refactor
This commit is contained in:
parent
ed646f6c71
commit
64ed4186b3
1 changed files with 24 additions and 33 deletions
57
cd.sh
57
cd.sh
|
@ -49,41 +49,30 @@ cd_set_environment () {
|
|||
exit 1
|
||||
;;
|
||||
esac
|
||||
# project / branch
|
||||
[ "${CI_COMMIT_BRANCH}" ] && CD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
|
||||
[ "${GITHUB_REF_NAME}" ] && CD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
|
||||
if [ ! "${CD_PROJECT_BRANCH}" ] ; then
|
||||
echo "CD_PROJECT_BRANCH"
|
||||
exit 3
|
||||
fi
|
||||
# project / name
|
||||
[ "${CI_PROJECT_PATH}" ] \
|
||||
&& CD_PROJECT_NAME="$(basename "${CI_PROJECT_PATH}")"
|
||||
[ "${GITHUB_REPOSITORY}" ] \
|
||||
&& CD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
|
||||
if [ ! "${CD_PROJECT_NAME}" ] ; then
|
||||
echo "CD_PROJECT_NAME"
|
||||
exit 3
|
||||
fi
|
||||
# projects / group
|
||||
[ "${CI_PROJECT_PATH}" ] \
|
||||
&& CD_PROJECTS_GROUP="$(dirname "${CI_PROJECT_PATH}")"
|
||||
[ "${GITHUB_REPOSITORY}" ] \
|
||||
&& CD_PROJECTS_GROUP="$(dirname "${GITHUB_REPOSITORY}")"
|
||||
if [ ! "${CD_PROJECTS_GROUP}" ] ; then
|
||||
echo "CD_PROJECTS_GROUP"
|
||||
exit 3
|
||||
fi
|
||||
# projects / url
|
||||
[ "${CI_SERVER_URL}" ] && CD_PROJECTS_URL="${CI_SERVER_URL}"
|
||||
[ "${GITHUB_SERVER_URL}" ] && CD_PROJECTS_URL="${GITHUB_SERVER_URL}"
|
||||
if [ "${CD_PROJECTS_URL}" ] ; then
|
||||
CD_PROJECTS_URL="${CD_PROJECTS_URL}/${CD_PROJECTS_GROUP}"
|
||||
# ci / github
|
||||
if [ "${GITHUB_ACTIONS}" ] ; then
|
||||
CD_SERVER_URL="${GITHUB_SERVER_URL}"
|
||||
CD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
|
||||
CD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
|
||||
CD_PROJECTS_GROUP="$(dirname "${GITHUB_REPOSITORY}")"
|
||||
# ci / gitlab
|
||||
elif [ "${GITLAB_CI}" ] ; then
|
||||
CD_SERVER_URL="${CI_SERVER_URL}"
|
||||
CD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
|
||||
CD_PROJECT_NAME="$(basename "${CI_PROJECT_PATH}")"
|
||||
CD_PROJECTS_GROUP="$(dirname "${CI_PROJECT_PATH}")"
|
||||
# ci / none
|
||||
else
|
||||
echo "CD_PROJECTS_URL"
|
||||
echo "CI"
|
||||
exit 3
|
||||
fi
|
||||
# project / url
|
||||
#
|
||||
[ "${CD_SERVER_URL}" ] || echo "CD_SERVER_URL" && exit 3
|
||||
[ "${CD_PROJECT_BRANCH}" ] || echo "CD_PROJECT_BRANCH" && exit 3
|
||||
[ "${CD_PROJECT_NAME}" ] || echo "CD_PROJECT_NAME" && exit 3
|
||||
[ "${CD_PROJECTS_GROUP}" ] || echo "CD_PROJECTS_GROUP" && exit 3
|
||||
#
|
||||
CD_PROJECTS_URL="${CD_SERVER_URL}/${CD_PROJECTS_GROUP}"
|
||||
CD_PROJECT_URL="${CD_PROJECTS_URL}/${CD_PROJECT_NAME}"
|
||||
#
|
||||
echo -n "\
|
||||
|
@ -95,11 +84,13 @@ CD_DNS_FILE=${CD_DNS_FILE}
|
|||
CD_PYTHON_COMMAND=${CD_PYTHON_COMMAND}
|
||||
CD_PYTHON_PACKAGES=${CD_PYTHON_PACKAGES}
|
||||
#
|
||||
CD_SERVER_URL=${CD_SERVER_URL}
|
||||
CD_PROJECT_BRANCH=${CD_PROJECT_BRANCH}
|
||||
CD_PROJECT_NAME=${CD_PROJECT_NAME}
|
||||
CD_PROJECT_URL=${CD_PROJECT_URL}
|
||||
CD_PROJECTS_GROUP=${CD_PROJECTS_GROUP}
|
||||
#
|
||||
CD_PROJECTS_URL=${CD_PROJECTS_URL}
|
||||
CD_PROJECT_URL=${CD_PROJECT_URL}
|
||||
"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue