Commit b2eb7c6a authored by Ruben ten Hove's avatar Ruben ten Hove
Browse files

Merge branch 'rhtenhove-beta-patch-41439' into 'beta'

ci: badge verbosity

See merge request just-ci/templates!31
parents 45926e3b d5216355
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -8,11 +8,9 @@
#   extends: .badge
#   variables:
#     NAME: "version"
#     MESSAGE: "1.2.3"
#     VALUE: "1.2.3"
#     COLOR: "red"
#     URL: "${CI_PROJECT_URL}/tags/${CI_COMMIT_TAG}"
#   rules:
#     - if: $GL_TOKEN

# Make sure your_custom_job is replaced and unique, and you've changed the variables
# according to your preferences.
@@ -29,11 +27,14 @@
  script:
    - IMAGE_URL=${CI_PROJECT_URL}/-/jobs/artifacts/${CI_DEFAULT_BRANCH}/raw/badges/${NAME}.svg?job=${CI_JOB_NAME}
    - mkdir -p ci_badges
    - anybadge -l "${NAME}" -v "${MESSAGE}" -c "${COLOR}" -f "ci_badges/${NAME}.svg"
    - anybadge -l "${NAME}" -v "${VALUE}" -c "${COLOR}" -f "ci_badges/${NAME}.svg"
    - |
      echo -e "[+] Created 'ci_badges/${NAME}.svg':\n- Label: '${NAME}'\n- Value: '${VALUE}'\n- Color: '${COLOR}'\n- URL: '${URL}'"

    - |
      if [ -z "${GL_TOKEN}" ]; then
        echo "[!] GL_TOKEN not set. You can check the badge in the artifacts. It will not be set."
        echo "[!] GL_TOKEN not set. You can check the badge in the artifacts. It will not be automatically installed/updated in your project."
        echo "[?] You can set it manually. Create/update a badge named '${NAME}' with the image URL '${IMAGE_URL}' and as the link URL '${URL:-$CI_PROJECT_URL}'."
      else
        echo "[*] Creating/updating badge..."
        BADGE_ID=$(curl -SsLf -H "PRIVATE-TOKEN: ${GL_TOKEN}" "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/badges" | jq --arg NAME "${NAME}" '.[] | select(.name==$NAME) | .id') || true
@@ -60,3 +61,5 @@
      - ci_badges/*.svg
    when: always
  allow_failure: true
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'