Commit 76cd5df6 authored by Federico Falconieri's avatar Federico Falconieri
Browse files

Merge branch 'beta' into 16-fix-enhance-grype-job

parents 649d46fa 8becb471
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -20,7 +20,7 @@ badge:test:
  stage: test
  variables:
    NAME: "branch"
    MESSAGE: "${CI_COMMIT_REF_NAME}"
    VALUE: "${CI_COMMIT_REF_NAME}"
    COLOR: "fuchsia"
  rules:
    - if: $GL_TOKEN
+11 −6
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.
@@ -27,13 +25,18 @@
  variables:
    GIT_STRATEGY: "none"
  script:
    - IMAGE_URL=${CI_PROJECT_URL}/-/jobs/artifacts/${CI_DEFAULT_BRANCH}/raw/badges/${NAME}.svg?job=${CI_JOB_NAME}
    - IMAGE_URL=${CI_PROJECT_URL}/-/jobs/artifacts/${CI_COMMIT_REF_SLUG}/raw/ci_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}."
        echo "[?] You can also set this badge anywhere else. Just reference the image ${IMAGE_URL}."
        exit 1
      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 +63,5 @@
      - ci_badges/*.svg
    when: always
  allow_failure: true
  rules:
    - if: '$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH'
+1 −1
Original line number Diff line number Diff line
@@ -39,7 +39,7 @@ badge:semantic-release:
  extends: .badge
  variables:
    NAME: "version"
    MESSAGE: "${CI_COMMIT_TAG}"
    VALUE: "${CI_COMMIT_TAG}"
    COLOR: "green"
    URL: "${CI_PROJECT_URL}/tags/${CI_COMMIT_TAG}"
  rules: