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