diff --git a/cd.sh b/cd.sh index f1ee1f8..fe937f4 100644 --- a/cd.sh +++ b/cd.sh @@ -7,62 +7,61 @@ CD_NAME='cd' CD_REPOSITORIES_PARENT='rwx' function cd_set_environment { - # CD_DNS_FILE='/etc/resolv.conf' CD_ENV="$(mktemp)" -case "${CD_OS_NAME}" in - 'debian') - CD_PYTHON_COMMAND='python3' - CD_PYTHON_PACKAGES='/usr/lib/python3/dist-packages' - case "${CD_OS_VERSION}" in - 'bookworm') - echo 'TODO' - ;; - *) - echo 'CD_OS_VERSION' - exit 2 - ;; - esac - ;; - *) - echo 'CD_OS_NAME' - 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_GROUP}" -else - echo 'CD_PROJECTS_URL' - exit 3 -fi + case "${CD_OS_NAME}" in + 'debian') + CD_PYTHON_COMMAND='python3' + CD_PYTHON_PACKAGES='/usr/lib/python3/dist-packages' + case "${CD_OS_VERSION}" in + 'bookworm') + echo 'TODO' + ;; + *) + echo 'CD_OS_VERSION' + exit 2 + ;; + esac + ;; + *) + echo 'CD_OS_NAME' + 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_GROUP}" + else + echo 'CD_PROJECTS_URL' + exit 3 + fi # project / url CD_PROJECT_URL="${CD_PROJECTS_URL}/${CD_PROJECT_NAME}" }