fix: remove leading and trailing - caracter

This commit is contained in:
romain lespinasse
2019-11-06 09:56:13 +01:00
committed by Romain Lespinasse
parent 93d0a6d6be
commit be6ec48344
2 changed files with 3 additions and 1 deletions

View File

@@ -6,7 +6,8 @@ This action slug and expose some github variables.
- put the variable content in lower case, - put the variable content in lower case,
- replace any caracter by `-` except `0-9` and `a-z`, - replace any caracter by `-` except `0-9` and `a-z`,
- limit the string size to 63 caracters - remove leading and trailing `-` caracter,
- limit the string size to 63 caracters.
## Environement Variables ## Environement Variables

View File

@@ -3,6 +3,7 @@
slug_ref() { slug_ref() {
echo "$1" \ echo "$1" \
| tr "[:upper:]" "[:lower:]" \ | tr "[:upper:]" "[:lower:]" \
| sed -r 's#refs/.*/##;s/[~\^]+//g;s/[^a-zA-Z0-9]+/-/g;s/^-+\|-+$//g;s/^-*//;s/-*$//' \
| cut -c1-63 | cut -c1-63
} }