mirror of
https://github.com/inttter/md-badges.git
synced 2026-05-06 10:26:57 +02:00
fix: 💚 GH actions: bugfix and add error handling
This commit is contained in:
parent
561bcae2ba
commit
ae2aa61968
1 changed files with 25 additions and 3 deletions
|
|
@ -8,9 +8,31 @@
|
||||||
#
|
#
|
||||||
# #################################################################################
|
# #################################################################################
|
||||||
|
|
||||||
|
# ===== Error handling =======
|
||||||
|
# set -e: exit on error
|
||||||
|
set -e
|
||||||
|
|
||||||
|
# invoke the catch() function whenever an error occurs
|
||||||
|
trap 'catch $? $LINENO' EXIT
|
||||||
|
|
||||||
|
# catch() function just prints an error message (before exit)
|
||||||
|
catch() {
|
||||||
|
if [ "$1" != "0" ]; then
|
||||||
|
# error handling goes here
|
||||||
|
echo " (Exiting due to return code $1 on line $2)" >&2
|
||||||
|
else
|
||||||
|
echo "Script completed successfully"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
# get a reference to the current directory
|
# get a reference to the current directory
|
||||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
||||||
|
# relative path to README.md
|
||||||
READMEFILE="${DIR}/../../../README.md"
|
READMEFILE="${DIR}/../../../README.md"
|
||||||
|
# temporary file
|
||||||
|
TEMPFILE="${DIR}/md-badges.md"
|
||||||
|
# relative path to output file
|
||||||
OUTFILE="${DIR}/../../../docs/REFERENCE_STYLE.md"
|
OUTFILE="${DIR}/../../../docs/REFERENCE_STYLE.md"
|
||||||
|
|
||||||
# extract the table rows from README.md, sort them, and pass them to
|
# extract the table rows from README.md, sort them, and pass them to
|
||||||
|
|
@ -22,10 +44,10 @@ readmerows=$(
|
||||||
sort
|
sort
|
||||||
)
|
)
|
||||||
|
|
||||||
# add a newline before processing with awk
|
# add a newline before processing with awk into TEMPFILE
|
||||||
printf "%s\n\n" "$readmerows" \
|
printf "%s\n\n" "$readmerows" \
|
||||||
| gawk --posix -F '|' -f "${DIR}/extract-refstyle-badges.awk" \
|
| gawk --posix -F '|' -f "${DIR}/extract-refstyle-badges.awk" \
|
||||||
> "${DIR}/md-badges.md"
|
> "${TEMPFILE}"
|
||||||
|
|
||||||
# now insert the generated md-badges.md content into README.md
|
# now insert the generated md-badges.md content into README.md
|
||||||
|
|
||||||
|
|
@ -35,7 +57,7 @@ tail='^<\!-- ### END GENERATED CONTENT -->'
|
||||||
sed -e "/$lead/,/$tail/{
|
sed -e "/$lead/,/$tail/{
|
||||||
/$lead/{
|
/$lead/{
|
||||||
p;
|
p;
|
||||||
r $DIR/md-badges.md
|
r $TEMPFILE
|
||||||
};
|
};
|
||||||
/$tail/p;
|
/$tail/p;
|
||||||
d
|
d
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue