ci comments

This commit is contained in:
Marc Beninca 2024-07-20 16:51:14 +02:00
parent c031b07b0f
commit 60f1a717c5
Signed by: marc.beninca
GPG key ID: 9C7613450C80C24F

21
spcd.sh
View file

@ -54,9 +54,9 @@ spcd_list_environment_variables() {
spcd_set_environment_variables() {
spcd_step "Set environment variables"
# continuous integration platform
# continuous integration / github → gitea → forgejo
if [ -n "${GITHUB_ACTIONS}" ]; then
# github → gitea → forgejo
# project root
if [ -n "${GITHUB_SERVER_URL}" ]; then
SPCD_PROJECT_ROOT="$(dirname "${GITHUB_SERVER_URL}")//"
[ -n "${GITHUB_TOKEN}" ] &&
@ -65,27 +65,38 @@ spcd_set_environment_variables() {
else
spcd_error_ci "GITHUB_SERVER_URL"
fi
# project path & name
if [ -n "${GITHUB_REPOSITORY}" ]; then
# project path
SPCD_PROJECT_PATH="$(dirname "${GITHUB_REPOSITORY}")"
# project name
SPCD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
else
spcd_error_ci "GITHUB_REPOSITORY"
fi
# project branch
if [ -n "${GITHUB_REF_NAME}" ]; then
SPCD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
else
spcd_error_ci "GITHUB_REF_NAME"
fi
# continuous integration / gitlab
elif [ -n "${GITLAB_CI}" ]; then
# gitlab
# project root / protocol
if [ -n "${CI_SERVER_PROTOCOL}" ]; then
# project root / login
if [ -n "${CI_REGISTRY_USER}" ]; then
# project root / password
if [ -n "${CI_REGISTRY_PASSWORD}" ]; then
# project root / host
if [ -n "${CI_SERVER_FQDN}" ]; then
# project root
SPCD_PROJECT_ROOT="${CI_SERVER_PROTOCOL}\
://${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}@${CI_SERVER_FQDN}"
# project path
if [ -n "${CI_PROJECT_NAMESPACE}" ]; then
SPCD_PROJECT_PATH="${CI_PROJECT_NAMESPACE}"
# project name
if [ -n "${CI_PROJECT_NAME}" ]; then
SPCD_PROJECT_NAME="${CI_PROJECT_NAME}"
else
@ -106,15 +117,17 @@ spcd_set_environment_variables() {
else
spcd_error_ci "CI_SERVER_PROTOCOL"
fi
# project branch
if [ -n "${CI_COMMIT_BRANCH}" ]; then
SPCD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
else
spcd_error_ci "CI_COMMIT_BRANCH"
fi
# continuous integration / unsupported
else
# unsupported
spcd_error_ci "ø"
fi
#
[ -n "${SPCD_PROJECT_ROOT}" ] || spcd_error_ci "SPCD_PROJECT_ROOT"
[ -n "${SPCD_PROJECT_PATH}" ] || spcd_error_ci "SPCD_PROJECT_PATH"
[ -n "${SPCD_PROJECT_NAME}" ] || spcd_error_ci "SPCD_PROJECT_NAME"