env/write,set
Some checks failed
/ job (push) Failing after 7s

This commit is contained in:
Marc Beninca 2024-04-27 11:56:16 +02:00
parent 99a9cd34d2
commit 118df2942e
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

37
cd.sh
View file

@ -6,7 +6,10 @@ CD_DNS_SERVERS=(
CD_NAME='cd' CD_NAME='cd'
CD_REPOSITORIES_PARENT='rwx' CD_REPOSITORIES_PARENT='rwx'
function cd_set_environment {
#
CD_DNS_FILE='/etc/resolv.conf' CD_DNS_FILE='/etc/resolv.conf'
CD_ENV="$(mktemp)"
case "${CD_OS_NAME}" in case "${CD_OS_NAME}" in
'debian') 'debian')
CD_PYTHON_COMMAND='python3' CD_PYTHON_COMMAND='python3'
@ -29,9 +32,7 @@ esac
# project / branch # project / branch
[ "${CI_COMMIT_BRANCH}" ] && export CD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}" [ "${CI_COMMIT_BRANCH}" ] && export CD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
[ "${GITHUB_REF_NAME}" ] && export CD_PROJECT_BRANCH="${GITHUB_REF_NAME}" [ "${GITHUB_REF_NAME}" ] && export CD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
if [ "${CD_PROJECT_BRANCH}" ] ; then if [ ! "${CD_PROJECT_BRANCH}" ] ; then
echo "CD_PROJECT_BRANCH = ${CD_PROJECT_BRANCH}"
else
echo 'CD_PROJECT_BRANCH' echo 'CD_PROJECT_BRANCH'
exit 3 exit 3
fi fi
@ -40,9 +41,7 @@ fi
&& CD_PROJECT_NAME="$(basename "${CI_PROJECT_PATH}")" && CD_PROJECT_NAME="$(basename "${CI_PROJECT_PATH}")"
[ "${GITHUB_REPOSITORY}" ] \ [ "${GITHUB_REPOSITORY}" ] \
&& CD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")" && CD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
if [ "${CD_PROJECT_NAME}" ] ; then if [ ! "${CD_PROJECT_NAME}" ] ; then
echo "CD_PROJECT_NAME = ${CD_PROJECT_NAME}"
else
echo 'CD_PROJECT_NAME' echo 'CD_PROJECT_NAME'
exit 3 exit 3
fi fi
@ -51,9 +50,7 @@ fi
&& CD_PROJECTS_GROUP="$(dirname "${CI_PROJECT_PATH}")" && CD_PROJECTS_GROUP="$(dirname "${CI_PROJECT_PATH}")"
[ "${GITHUB_REPOSITORY}" ] \ [ "${GITHUB_REPOSITORY}" ] \
&& CD_PROJECTS_GROUP="$(dirname "${GITHUB_REPOSITORY}")" && CD_PROJECTS_GROUP="$(dirname "${GITHUB_REPOSITORY}")"
if [ "${CD_PROJECTS_GROUP}" ] ; then if [ ! "${CD_PROJECTS_GROUP}" ] ; then
echo "CD_PROJECTS_GROUP = ${CD_PROJECTS_GROUP}"
else
echo 'CD_PROJECTS_GROUP' echo 'CD_PROJECTS_GROUP'
exit 3 exit 3
fi fi
@ -62,14 +59,28 @@ fi
[ "${GITHUB_SERVER_URL}" ] && CD_PROJECTS_URL="${GITHUB_SERVER_URL}" [ "${GITHUB_SERVER_URL}" ] && CD_PROJECTS_URL="${GITHUB_SERVER_URL}"
if [ "${CD_PROJECTS_URL}" ] ; then if [ "${CD_PROJECTS_URL}" ] ; then
CD_PROJECTS_URL+="/${CD_PROJECTS_GROUP}" CD_PROJECTS_URL+="/${CD_PROJECTS_GROUP}"
echo "CD_PROJECTS_URL = ${CD_PROJECTS_URL}"
else else
echo 'CD_PROJECTS_URL' echo 'CD_PROJECTS_URL'
exit 3 exit 3
fi fi
# project / url # project / url
CD_PROJECT_URL="${CD_PROJECTS_URL}/${CD_PROJECT_NAME}" CD_PROJECT_URL="${CD_PROJECTS_URL}/${CD_PROJECT_NAME}"
echo "CD_PROJECT_URL = ${CD_PROJECT_URL}" }
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 { function cd_step {
if [ "${1}" ] ; then if [ "${1}" ] ; then
@ -239,10 +250,12 @@ local root
function cd_bootstrap { function cd_bootstrap {
cd_step "${FUNCNAME}" cd_step "${FUNCNAME}"
"${CD_PYTHON_COMMAND}" -m "${CD_NAME}" "${CD_PYTHON_COMMAND}" -m "${CD_NAME}" "${CD_ENV}"
} }
function cd_main { function cd_main {
cd_set_environment
cd_write_environment
cd_set_dns_resolving cd_set_dns_resolving
cd_set_packages_repositories cd_set_packages_repositories
cd_set_packages_configuration cd_set_packages_configuration