Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TOAR-II FastAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
esde
toar-data
TOAR-II FastAPI
Commits
becd3e97
Commit
becd3e97
authored
4 months ago
by
Sabine Schröder
Browse files
Options
Downloads
Patches
Plain Diff
Upload update_badge.sh from Geopeas
(author: Lukas Leufen)
parent
e8a49f9b
No related branches found
No related tags found
No related merge requests found
Pipeline
#244838
failed
4 months ago
Stage: test
Stage: deploy
Stage: pages
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
CI/update_badge.sh
+93
-0
93 additions, 0 deletions
CI/update_badge.sh
with
93 additions
and
0 deletions
CI/update_badge.sh
0 → 100644
+
93
−
0
View file @
becd3e97
#!/bin/bash
# 'running', 'success' or 'failure' is in this file
if
[[
-e
status.txt
]]
;
then
EXIT_STATUS
=
`
cat
status.txt
`
else
EXIT_STATUS
=
"running"
fi
printf
"%s
\n
"
${
EXIT_STATUS
}
# fetch badge_status
BADGE_STATUS
=
"
${
CI_COMMIT_REF_NAME
}
:
${
CI_JOB_NAME
}
"
# replace - with --
BADGE_STATUS
=
$(
echo
-e
"
${
BADGE_STATUS
//\-/--
}
"
)
# Set values for shields.io fields based on STATUS
if
[[
${
EXIT_STATUS
}
=
"running"
]]
;
then
BADGE_SUBJECT
=
"running"
BADGE_COLOR
=
"lightgrey"
elif
[[
${
EXIT_STATUS
}
=
"failure"
]]
;
then
BADGE_SUBJECT
=
"failed"
BADGE_COLOR
=
"red"
elif
[[
${
EXIT_STATUS
}
=
"success"
]]
;
then
BADGE_SUBJECT
=
"passed"
BADGE_COLOR
=
"brightgreen"
if
[[
-e
success.txt
]]
;
then
SUCCESS_MESSAGE
=
`
cat
success.txt
`
BADGE_SUBJECT
=
"
${
SUCCESS_MESSAGE
}
"
fi
elif
[[
${
EXIT_STATUS
}
=
"incomplete"
]]
;
then
EXIT_STATUS_MESSAGE
=
`
cat
incomplete.txt
`
BADGE_SUBJECT
=
"
${
EXIT_STATUS_MESSAGE
}
"
EXIT_STATUS_RATIO
=
"
$(
echo
${
EXIT_STATUS_MESSAGE
}
|
(
grep
-oP
'\d*'
)
|
head
-1
)
"
printf
"%s
\n
"
${
EXIT_STATUS_RATIO
}
if
[[
"
${
EXIT_STATUS_RATIO
}
"
-lt
"
${
FAILURE_THRESHOLD
}
"
]]
;
then
BADGE_COLOR
=
"red"
else
BADGE_COLOR
=
"yellow"
fi
else
exit
1
fi
# load additional options
while
getopts
b:c:s: option
do
case
${
option
}
in
b
)
BADGE_STATUS
=
$(
echo
-e
"
${
OPTARG
//\-/--
}
"
)
;;
c
)
BADGE_COLOR
=
$(
echo
-e
"
${
OPTARG
//\-/--
}
"
)
;;
s
)
BADGE_SUBJECT
=
$(
echo
-e
"
${
OPTARG
//\-/--
}
"
)
;;
esac
done
# Set filename for the badge (i.e. 'ci-test-branch-job.svg')
CI_COMMIT_REF_NAME_NO_SLASH
=
"
$(
echo
-e
"
${
CI_COMMIT_REF_NAME
}
"
|
tr
'/'
'_'
)
"
if
[[
${
BADGE_STATUS
}
=
"version"
]]
;
then
BADGE_FILENAME
=
"badge_version.svg"
else
BADGE_FILENAME
=
"badge_
${
CI_COMMIT_REF_NAME_NO_SLASH
}
-
${
CI_JOB_NAME
}
.svg"
fi
RECENT_BADGE_FILENAME
=
"badge_recent-
${
CI_JOB_NAME
}
.svg"
# Get the badge from shields.io
SHIELDS_IO_NAME
=
${
BADGE_STATUS
}
-
${
BADGE_SUBJECT
}
-
${
BADGE_COLOR
}
.svg
printf
"%s
\n
"
"INFO: Fetching badge
${
SHIELDS_IO_NAME
}
from shields.io to
${
BADGE_FILENAME
}
."
printf
"%s
\n
"
"
${
SHIELDS_IO_NAME
//\_/__
}
"
printf
"%s
\n
"
"
${
SHIELDS_IO_NAME
//\#/%23
}
"
SHIELDS_IO_NAME
=
"
$(
echo
-e
"
${
SHIELDS_IO_NAME
//\_/__
}
"
)
"
SHIELDS_IO_NAME
=
"
$(
echo
-e
"
${
SHIELDS_IO_NAME
//\#/%23
}
"
)
"
curl
"https://img.shields.io/badge/
${
SHIELDS_IO_NAME
}
"
>
${
BADGE_FILENAME
}
echo
"https://img.shields.io/badge/
${
SHIELDS_IO_NAME
}
"
SHIELDS_IO_NAME_RECENT
=
"RECENT:
${
SHIELDS_IO_NAME
}
"
curl
"https://img.shields.io/badge/
${
SHIELDS_IO_NAME_RECENT
}
"
>
${
RECENT_BADGE_FILENAME
}
echo
"
${
SHIELDS_IO_NAME_RECENT
}
"
>
testRecentName.txt
#
if
[[
!
-d
./badges
]]
;
then
# Control will enter here if $DIRECTORY doesn't exist.
mkdir
badges/
fi
mv
${
BADGE_FILENAME
}
./badges/.
# replace outdated recent badge by new badge
mv
${
RECENT_BADGE_FILENAME
}
./badges/
${
RECENT_BADGE_FILENAME
}
# set status to failed, this will be overwritten if job ended with exitcode 0
echo
"failed"
>
status.txt
exit
0
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment