diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 86ce9dc7..4b2e4ec6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -35,7 +35,7 @@ deploy_job: # Generate successful status badge - mkdir -p .gitlab/ - - wget https://img.shields.io/badge/pipeline-passed-success.svg -O .gitlab/status.svg + - sh utils/badge.sh "success" - git add .gitlab/status.svg # Only commit when diff exists https://stackoverflow.com/a/8123841 - git diff-index --quiet HEAD || git commit -m "Success pipeline" @@ -76,7 +76,7 @@ failed_job: - git config --global user.email "3048979-curben-bot@users.noreply.gitlab.com" - mkdir -p .gitlab/ - - wget https://img.shields.io/badge/pipeline-failed-critical.svg -O .gitlab/status.svg + - sh utils/badge.sh "failed" - git add .gitlab/status.svg - git diff-index --quiet HEAD || git commit -m "Failed pipeline" - ssh -T git@gitlab.com diff --git a/.gitlab/status.svg b/.gitlab/status.svg index da986c3c..f9deff17 100644 --- a/.gitlab/status.svg +++ b/.gitlab/status.svg @@ -1 +1 @@ - pipelinepipelinepassedpassed \ No newline at end of file + pipelinepipelinepassedpassed diff --git a/utils/badge.sh b/utils/badge.sh new file mode 100644 index 00000000..e3bed90f --- /dev/null +++ b/utils/badge.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +set -efux -o pipefail + +## Set status badge + +successBadge=' pipelinepipelinepassedpassed ' + +failedBadge=' pipelinepipelinefailedfailed ' + +if [ "$1" = "success" ]; then + echo "$successBadge" > ".gitlab/status.svg" +elif [ "$1" = "failed" ]; then + echo "$failedBadge" > ".gitlab/status.svg" +fi