ci
This commit is contained in:
parent
3922c14f69
commit
7de27df47b
1 changed files with 69 additions and 69 deletions
138
spcd.sh
138
spcd.sh
|
@ -59,6 +59,75 @@ spcd_list_working_directory() {
|
||||||
|
|
||||||
spcd_set_environment_variables() {
|
spcd_set_environment_variables() {
|
||||||
spcd_step "Set environment variables"
|
spcd_step "Set environment variables"
|
||||||
|
# continuous integration platform
|
||||||
|
if [ -n "${GITHUB_ACTIONS}" ]; then
|
||||||
|
# github → gitea → forgejo
|
||||||
|
if [ -n "${GITHUB_SERVER_URL}" ]; then
|
||||||
|
SPCD_PROJECT_ROOT="$(dirname "${GITHUB_SERVER_URL}")//"
|
||||||
|
[ -n "${GITHUB_TOKEN}" ] &&
|
||||||
|
SPCD_PROJECT_ROOT="${SPCD_PROJECT_ROOT}${GITHUB_TOKEN}@"
|
||||||
|
SPCD_PROJECT_ROOT="${SPCD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")"
|
||||||
|
else
|
||||||
|
spcd_error_ci "GITHUB_SERVER_URL"
|
||||||
|
fi
|
||||||
|
if [ -n "${GITHUB_REPOSITORY}" ]; then
|
||||||
|
SPCD_PROJECT_PATH="$(dirname "${GITHUB_REPOSITORY}")"
|
||||||
|
SPCD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
|
||||||
|
else
|
||||||
|
spcd_error_ci "GITHUB_REPOSITORY"
|
||||||
|
fi
|
||||||
|
if [ -n "${GITHUB_REF_NAME}" ]; then
|
||||||
|
SPCD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
|
||||||
|
else
|
||||||
|
spcd_error_ci "GITHUB_REF_NAME"
|
||||||
|
fi
|
||||||
|
elif [ -n "${GITLAB_CI}" ]; then
|
||||||
|
# gitlab
|
||||||
|
if [ -n "${CI_SERVER_PROTOCOL}" ]; then
|
||||||
|
if [ -n "${CI_REGISTRY_USER}" ]; then
|
||||||
|
if [ -n "${CI_REGISTRY_PASSWORD}" ]; then
|
||||||
|
if [ -n "${CI_SERVER_FQDN}" ]; then
|
||||||
|
SPCD_PROJECT_ROOT="${CI_SERVER_PROTOCOL}\
|
||||||
|
://${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}@${CI_SERVER_FQDN}"
|
||||||
|
if [ -n "${CI_PROJECT_NAMESPACE}" ]; then
|
||||||
|
SPCD_PROJECT_PATH="${CI_PROJECT_NAMESPACE}"
|
||||||
|
if [ -n "${CI_PROJECT_NAME}" ]; then
|
||||||
|
SPCD_PROJECT_NAME="${CI_PROJECT_NAME}"
|
||||||
|
else
|
||||||
|
spcd_error_ci "CI_PROJECT_NAME"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
spcd_error_ci "CI_PROJECT_NAMESPACE"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
spcd_error_ci "CI_SERVER_FQDN"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
spcd_error_ci "CI_REGISTRY_PASSWORD"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
spcd_error_ci "CI_REGISTRY_USER"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
spcd_error_ci "CI_SERVER_PROTOCOL"
|
||||||
|
fi
|
||||||
|
if [ -n "${CI_COMMIT_BRANCH}" ]; then
|
||||||
|
SPCD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
|
||||||
|
else
|
||||||
|
spcd_error_ci "CI_COMMIT_BRANCH"
|
||||||
|
fi
|
||||||
|
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"
|
||||||
|
[ -n "${SPCD_PROJECT_BRANCH}" ] || spcd_error_ci "SPCD_PROJECT_BRANCH"
|
||||||
|
#
|
||||||
|
spcd_split
|
||||||
|
spcd_echo "SPCD_PROJECT_ROOT" \
|
||||||
|
"SPCD_PROJECT_PATH" "SPCD_PROJECT_NAME" "SPCD_PROJECT_BRANCH"
|
||||||
# set path
|
# set path
|
||||||
SPCD_PATH="$(realpath "${0}")"
|
SPCD_PATH="$(realpath "${0}")"
|
||||||
spcd_echo "SPCD_PATH"
|
spcd_echo "SPCD_PATH"
|
||||||
|
@ -370,75 +439,6 @@ Acquire::https::Verify-Peer False;
|
||||||
#
|
#
|
||||||
spcd_split
|
spcd_split
|
||||||
spcd_echo "SPCD_CA"
|
spcd_echo "SPCD_CA"
|
||||||
# continuous integration platform
|
|
||||||
if [ -n "${GITHUB_ACTIONS}" ]; then
|
|
||||||
# github → gitea → forgejo
|
|
||||||
if [ -n "${GITHUB_SERVER_URL}" ]; then
|
|
||||||
SPCD_PROJECT_ROOT="$(dirname "${GITHUB_SERVER_URL}")//"
|
|
||||||
[ -n "${GITHUB_TOKEN}" ] &&
|
|
||||||
SPCD_PROJECT_ROOT="${SPCD_PROJECT_ROOT}${GITHUB_TOKEN}@"
|
|
||||||
SPCD_PROJECT_ROOT="${SPCD_PROJECT_ROOT}$(basename "${GITHUB_SERVER_URL}")"
|
|
||||||
else
|
|
||||||
spcd_error_ci "GITHUB_SERVER_URL"
|
|
||||||
fi
|
|
||||||
if [ -n "${GITHUB_REPOSITORY}" ]; then
|
|
||||||
SPCD_PROJECT_PATH="$(dirname "${GITHUB_REPOSITORY}")"
|
|
||||||
SPCD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")"
|
|
||||||
else
|
|
||||||
spcd_error_ci "GITHUB_REPOSITORY"
|
|
||||||
fi
|
|
||||||
if [ -n "${GITHUB_REF_NAME}" ]; then
|
|
||||||
SPCD_PROJECT_BRANCH="${GITHUB_REF_NAME}"
|
|
||||||
else
|
|
||||||
spcd_error_ci "GITHUB_REF_NAME"
|
|
||||||
fi
|
|
||||||
elif [ -n "${GITLAB_CI}" ]; then
|
|
||||||
# gitlab
|
|
||||||
if [ -n "${CI_SERVER_PROTOCOL}" ]; then
|
|
||||||
if [ -n "${CI_REGISTRY_USER}" ]; then
|
|
||||||
if [ -n "${CI_REGISTRY_PASSWORD}" ]; then
|
|
||||||
if [ -n "${CI_SERVER_FQDN}" ]; then
|
|
||||||
SPCD_PROJECT_ROOT="${CI_SERVER_PROTOCOL}\
|
|
||||||
://${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}@${CI_SERVER_FQDN}"
|
|
||||||
if [ -n "${CI_PROJECT_NAMESPACE}" ]; then
|
|
||||||
SPCD_PROJECT_PATH="${CI_PROJECT_NAMESPACE}"
|
|
||||||
if [ -n "${CI_PROJECT_NAME}" ]; then
|
|
||||||
SPCD_PROJECT_NAME="${CI_PROJECT_NAME}"
|
|
||||||
else
|
|
||||||
spcd_error_ci "CI_PROJECT_NAME"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
spcd_error_ci "CI_PROJECT_NAMESPACE"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
spcd_error_ci "CI_SERVER_FQDN"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
spcd_error_ci "CI_REGISTRY_PASSWORD"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
spcd_error_ci "CI_REGISTRY_USER"
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
spcd_error_ci "CI_SERVER_PROTOCOL"
|
|
||||||
fi
|
|
||||||
if [ -n "${CI_COMMIT_BRANCH}" ]; then
|
|
||||||
SPCD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}"
|
|
||||||
else
|
|
||||||
spcd_error_ci "CI_COMMIT_BRANCH"
|
|
||||||
fi
|
|
||||||
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"
|
|
||||||
[ -n "${SPCD_PROJECT_BRANCH}" ] || spcd_error_ci "SPCD_PROJECT_BRANCH"
|
|
||||||
#
|
|
||||||
spcd_split
|
|
||||||
spcd_echo "SPCD_PROJECT_ROOT" \
|
|
||||||
"SPCD_PROJECT_PATH" "SPCD_PROJECT_NAME" "SPCD_PROJECT_BRANCH"
|
|
||||||
# TODO move to Python
|
# TODO move to Python
|
||||||
case "${SPCD_PM}" in
|
case "${SPCD_PM}" in
|
||||||
"${SPCD_PM_APK}" | "${SPCD_PM_APT}") SPCD_PKG_SSH="openssh-client" ;;
|
"${SPCD_PM_APK}" | "${SPCD_PM_APT}") SPCD_PKG_SSH="openssh-client" ;;
|
||||||
|
|
Loading…
Reference in a new issue