From 9f0251272b38a47ddbe04327c6a6640ea698210f Mon Sep 17 00:00:00 2001
From: Martin Weise <martin.weise@tuwien.ac.at>
Date: Sat, 28 Sep 2024 11:44:56 +0200
Subject: [PATCH] Added badge logic

---
 .docs/index.md   | 1 -
 .gitlab-ci.yml   | 4 ++--
 requirements.txt | 3 ++-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/.docs/index.md b/.docs/index.md
index 164db61387..9743a1a0a4 100644
--- a/.docs/index.md
+++ b/.docs/index.md
@@ -3,7 +3,6 @@ author: Martin Weise
 ---
 
 [![CI/CD Pipeline](../images/pipeline.svg)](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services){ tabindex=-1 }
-[![Code Coverage](../images/coverage.svg)](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services){ tabindex=-1 }
 [![GitLab Release](https://img.shields.io/gitlab/v/release/fair-data-austria-db-repository%2Ffda-services?gitlab_url=https%3A%2F%2Fgitlab.phaidra.org&display_name=release&style=flat&cacheSeconds=3600)](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services){ tabindex=-1 }
 [![Image Pulls](https://img.shields.io/docker/pulls/dbrepo/data-service?style=flat&cacheSeconds=3600)](https://hub.docker.com/u/dbrepo){ tabindex=-1 }
 [![GitLab License](https://img.shields.io/gitlab/license/fair-data-austria-db-repository%2Ffda-services?gitlab_url=https%3A%2F%2Fgitlab.phaidra.org%2F&style=flat&cacheSeconds=3600)](https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services){ tabindex=-1 }
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 1c14db2098..6cea36d850 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -441,8 +441,8 @@ release-docs:
     - "cp .docs/.swagger/custom.css ./final/${APP_VERSION}/rest/custom.css" # swagger
     - "cp -r ./site/* ./final/${APP_VERSION}" # mkdocs
     - "cp .docker/dist.tar.gz ./final/${APP_VERSION}/dist.tar.gz" # dist
-    - "wget -O ./final/${APP_VERSION}/images/pipeline.svg https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/badges/${CI_COMMIT_BRANCH}/pipeline.svg"
-    - "wget -O ./final/${APP_VERSION}/images/coverage.svg https://gitlab.phaidra.org/fair-data-austria-db-repository/fda-services/badges/${CI_COMMIT_BRANCH}/coverage.svg"
+    - "anybadge --label pipeline --value $(curl -fsSL -H 'PRIVATE-TOKEN: ${CI_TOKEN}' 'https://gitlab.phaidra.org/api/v4/projects/450/pipelines?ref=${CI_COMMIT_BRANCH}' | jq '[.[]|select(.)][0].status')  --file '/tmp/pipeline.svg' failed=red success=green"
+    - "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/requirements.txt b/requirements.txt
index 6442ea6075..659eb487ea 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -14,4 +14,5 @@ requests==2.31.0
 pika==1.3.2
 pydantic==2.6.4
 tuspy==1.0.3
-mike==2.0.0
\ No newline at end of file
+mike==2.0.0
+anybadge==1.14.0
\ No newline at end of file
-- 
GitLab