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
|
exit 1
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
# project / branch
|
# ci / github
|
||||||
[ "${CI_COMMIT_BRANCH}" ] && CD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
|
if [ "${GITHUB_ACTIONS}" ] ; then
|
||||||
[ "${GITHUB_REF_NAME}" ] && CD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
|
CD_SERVER_URL="${GITHUB_SERVER_URL}"
|
||||||
if [ ! "${CD_PROJECT_BRANCH}" ] ; then
|
CD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
|
||||||
echo "CD_PROJECT_BRANCH"
|
CD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
|
||||||
exit 3
|
CD_PROJECTS_GROUP="$(dirname "${GITHUB_REPOSITORY}")"
|
||||||
fi
|
# ci / gitlab
|
||||||
# project / name
|
elif [ "${GITLAB_CI}" ] ; then
|
||||||
[ "${CI_PROJECT_PATH}" ] \
|
CD_SERVER_URL="${CI_SERVER_URL}"
|
||||||
&& CD_PROJECT_NAME="$(basename "${CI_PROJECT_PATH}")"
|
CD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
|
||||||
[ "${GITHUB_REPOSITORY}" ] \
|
CD_PROJECT_NAME="$(basename "${CI_PROJECT_PATH}")"
|
||||||
&& CD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
|
CD_PROJECTS_GROUP="$(dirname "${CI_PROJECT_PATH}")"
|
||||||
if [ ! "${CD_PROJECT_NAME}" ] ; then
|
# ci / none
|
||||||
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}"
|
|
||||||
else
|
else
|
||||||
echo "CD_PROJECTS_URL"
|
echo "CI"
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
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}"
|
CD_PROJECT_URL="${CD_PROJECTS_URL}/${CD_PROJECT_NAME}"
|
||||||
#
|
#
|
||||||
echo -n "\
|
echo -n "\
|
||||||
|
@ -95,11 +84,13 @@ CD_DNS_FILE=${CD_DNS_FILE}
|
||||||
CD_PYTHON_COMMAND=${CD_PYTHON_COMMAND}
|
CD_PYTHON_COMMAND=${CD_PYTHON_COMMAND}
|
||||||
CD_PYTHON_PACKAGES=${CD_PYTHON_PACKAGES}
|
CD_PYTHON_PACKAGES=${CD_PYTHON_PACKAGES}
|
||||||
#
|
#
|
||||||
|
CD_SERVER_URL=${CD_SERVER_URL}
|
||||||
CD_PROJECT_BRANCH=${CD_PROJECT_BRANCH}
|
CD_PROJECT_BRANCH=${CD_PROJECT_BRANCH}
|
||||||
CD_PROJECT_NAME=${CD_PROJECT_NAME}
|
CD_PROJECT_NAME=${CD_PROJECT_NAME}
|
||||||
CD_PROJECT_URL=${CD_PROJECT_URL}
|
|
||||||
CD_PROJECTS_GROUP=${CD_PROJECTS_GROUP}
|
CD_PROJECTS_GROUP=${CD_PROJECTS_GROUP}
|
||||||
|
#
|
||||||
CD_PROJECTS_URL=${CD_PROJECTS_URL}
|
CD_PROJECTS_URL=${CD_PROJECTS_URL}
|
||||||
|
CD_PROJECT_URL=${CD_PROJECT_URL}
|
||||||
"
|
"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue