diff --git a/pidd.sh b/pidd.sh index 39ff68c..85b7c02 100644 --- a/pidd.sh +++ b/pidd.sh @@ -352,12 +352,17 @@ Acquire::https::Verify-Peer False; if [ -n "${GITHUB_ACTIONS}" ] ; then # github → gitea → forgejo if [ -n "${GITHUB_SERVER_URL}" ] ; then - PIDD_SERVER_URL="${GITHUB_SERVER_URL}" + if [ -n "${GITHUB_TOKEN}" ] ; then + PIDD_PROJECT_ROOT="$(dirname "${GITHUB_SERVER_URL}")\ +/${GITHUB_TOKEN}@$(basename "${GITHUB_SERVER_URL}")" + else + pidd_error_ci "GITHUB_TOKEN" + fi else pidd_error_ci "GITHUB_SERVER_URL" fi if [ -n "${GITHUB_REPOSITORY}" ] ; then - PIDD_PROJECTS_GROUP="$(dirname "${GITHUB_REPOSITORY}")" + PIDD_PROJECT_PATH="$(dirname "${GITHUB_REPOSITORY}")" PIDD_PROJECT_NAME="$(basename "${GITHUB_REPOSITORY}")" else pidd_error_ci "GITHUB_REPOSITORY" @@ -369,16 +374,33 @@ Acquire::https::Verify-Peer False; fi elif [ -n "${GITLAB_CI}" ] ; then # gitlab - if [ -n "${CI_SERVER_URL}" ] ; then - PIDD_SERVER_URL="${CI_SERVER_URL}" + if [ -n "${CI_SERVER_PROTOCOL}" ] ; then + if [ -n "${CI_REGISTRY_USER}" ] ; then + if [ -n "${CI_REGISTRY_PASSWORD}" ] ; then + if [ -n "${CI_SERVER_FQDN}" ] ; then + PIDD_PROJECT_ROOT="${CI_SERVER_PROTOCOL}\ +://${CI_REGISTRY_USER}:${CI_REGISTRY_PASSWORD}@${CI_SERVER_FQDN}" + if [ -n "${CI_PROJECT_NAMESPACE}" ] ; then + PIDD_PROJECT_PATH="${CI_PROJECT_NAMESPACE}" + if [ -n "${CI_PROJECT_NAME}" ] ; then + PIDD_PROJECT_NAME="${CI_PROJECT_NAME}" + else + pidd_error_ci "CI_PROJECT_NAME" + fi + else + pidd_error_ci "CI_PROJECT_NAMESPACE" + fi + else + pidd_error_ci "CI_SERVER_FQDN" + fi + else + pidd_error_ci "CI_REGISTRY_PASSWORD" + fi + else + pidd_error_ci "CI_REGISTRY_USER" + fi else - pidd_error_ci "CI_SERVER_URL" - fi - if [ -n "${CI_PROJECT_PATH}" ] ; then - PIDD_PROJECTS_GROUP="$(dirname "${CI_PROJECT_PATH}")" - PIDD_PROJECT_NAME="$(basename "${CI_PROJECT_PATH}")" - else - pidd_error_ci "CI_PROJECT_PATH" + pidd_error_ci "CI_SERVER_PROTOCOL" fi if [ -n "${CI_COMMIT_BRANCH}" ] ; then PIDD_PROJECT_BRANCH="${CI_COMMIT_BRANCH}" @@ -389,18 +411,18 @@ Acquire::https::Verify-Peer False; # unsupported pidd_error_ci "ø" fi - [ -n "${PIDD_SERVER_URL}" ] || pidd_error_ci "PIDD_SERVER_URL" - [ -n "${PIDD_PROJECTS_GROUP}" ] || pidd_error_ci "PIDD_PROJECTS_GROUP" + [ -n "${PIDD_PROJECT_ROOT}" ] || pidd_error_ci "PIDD_PROJECT_ROOT" + [ -n "${PIDD_PROJECT_PATH}" ] || pidd_error_ci "PIDD_PROJECT_PATH" [ -n "${PIDD_PROJECT_NAME}" ] || pidd_error_ci "PIDD_PROJECT_NAME" [ -n "${PIDD_PROJECT_BRANCH}" ] || pidd_error_ci "PIDD_PROJECT_BRANCH" # - PIDD_PROJECTS_URL="${PIDD_SERVER_URL}/${PIDD_PROJECTS_GROUP}" + PIDD_PROJECTS_URL="${PIDD_PROJECT_ROOT}/${PIDD_PROJECT_PATH}" # pidd_split pidd_echo "PIDD_CA" pidd_split - pidd_echo "PIDD_SERVER_URL" \ - "PIDD_PROJECTS_GROUP" "PIDD_PROJECT_NAME" "PIDD_PROJECT_BRANCH" + pidd_echo "PIDD_PROJECT_ROOT" \ + "PIDD_PROJECT_PATH" "PIDD_PROJECT_NAME" "PIDD_PROJECT_BRANCH" pidd_split pidd_echo "PIDD_PROJECTS_URL" # TODO move to Python