diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 5d73144915acb3f827b762420620d992036bb011..9f048df9a44ad1812a3cd0b0f8298c7ad459759d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -394,7 +394,6 @@ release-docs: - "cp -r ./site/* ./final/${APP_VERSION}" # mkdocs - "cp .docker/dist.tar.gz ./final/${APP_VERSION}/dist.tar.gz" # dist - "bash ./.gitlab/gen-badge.sh" - - "cp /tmp/pipeline.svg ./final/${APP_VERSION}/images/pipeline.svg" # badges - eval $(ssh-agent -s) - "mkdir -p /root/.ssh" - echo "$CI_KEY_PRIVATE" > /root/.ssh/id_rsa && chmod 0600 /root/.ssh/id_rsa diff --git a/.gitlab/gen-badge.sh b/.gitlab/gen-badge.sh index 8d4290b83d8a678e5ff8fa6efda13eb056dd3ee6..d5dd61b784823e148de71ad6eaae5db72bf64659 100644 --- a/.gitlab/gen-badge.sh +++ b/.gitlab/gen-badge.sh @@ -1,9 +1,12 @@ #!/bin/bash GITLAB_URL="https://gitlab.phaidra.org" PIPELINE_STATUS=$(curl -fsSL -H "PRIVATE-TOKEN: ${CI_TOKEN}" "${GITLAB_URL}/api/v4/projects/450/pipelines/latest?ref=${CI_COMMIT_BRANCH}" | jq --raw-output .detailed_status.text) -anybadge --label pipeline --value "${PIPELINE_STATUS}" failed=red passed=green canceled=darkgray > /tmp/pipeline.svg +echo "[INFO] pipeline status: ${PIPELINE_STATUS}" +anybadge --label pipeline --value "${PIPELINE_STATUS}" failed=red passed=green canceled=darkgray > "./final/${APP_VERSION}/images/pipeline.svg" PIPELINE_COVERAGE=$(curl -fsSL -H "PRIVATE-TOKEN: ${CI_TOKEN}" "${GITLAB_URL}/api/v4/projects/450/pipelines/latest?ref=${CI_COMMIT_BRANCH}" | jq --raw-output .coverage) -if [ "${PIPELINE_COVERAGE}" == "null" ]; then - PIPELINE_COVERAGE="unknown" +echo "[INFO] pipeline coverage: ${PIPELINE_COVERAGE}" +if [ "${PIPELINE_COVERAGE}" != "null" ]; then + anybadge --label pipeline --value "${PIPELINE_COVERAGE}" unknown=darkgray 70=red 80=orange 90=yellow 95=green > "./final/${APP_VERSION}/images/coverage.svg" +else + echo "[WARNING] Skipping badge generation, displaying default badge text: unknown" fi -anybadge --label pipeline --value "${PIPELINE_COVERAGE}" unknown=darkgray 70=red 80=orange 90=yellow 95=green > /tmp/coverage.svg