From 7de27df47b8819f29dd89e2c92169f833fedd4c3 Mon Sep 17 00:00:00 2001 From: Marc Beninca Date: Fri, 19 Jul 2024 21:59:09 +0200 Subject: [PATCH] ci --- spcd.sh | 138 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 69 insertions(+), 69 deletions(-) diff --git a/spcd.sh b/spcd.sh index 08abab7..2b96360 100644 --- a/spcd.sh +++ b/spcd.sh @@ -59,6 +59,75 @@ spcd_list_working_directory() { spcd_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 SPCD_PATH="$(realpath "${0}")" spcd_echo "SPCD_PATH" @@ -370,75 +439,6 @@ Acquire::https::Verify-Peer False; # spcd_split 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 case "${SPCD_PM}" in "${SPCD_PM_APK}" | "${SPCD_PM_APT}") SPCD_PKG_SSH="openssh-client" ;;