Compare commits

...

3 Commits
1.0.0 ... 1.0.1

Author SHA1 Message Date
romain lespinasse
e461860662 build: release 1.0.1 2019-11-06 10:29:40 +01:00
romain lespinasse
be6ec48344 fix: remove leading and trailing - caracter 2019-11-06 10:04:25 +01:00
romain lespinasse
93d0a6d6be refactor: apply shellcheck recommandation 2019-11-06 10:04:25 +01:00
2 changed files with 9 additions and 8 deletions

View File

@@ -6,7 +6,8 @@ This action slug and expose some github variables.
- put the variable content in lower case,
- 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
@@ -19,7 +20,7 @@ This action slug and expose some github variables.
## Example usage
```yaml
- uses: rlespinasse/github-slug-action@1.0.0
- uses: rlespinasse/github-slug-action@1.0.1
- name: Print slug variables
run: |
echo ${{ env.GITHUB_REF_SLUG }}

View File

@@ -1,12 +1,12 @@
#!/bin/sh -l
slug_ref() {
echo $1 \
| tr A-Z a-z \
| sed -r 's#refs/.*/##;s/[~\^]+//g;s/[^a-zA-Z0-9]+/-/g;s/^-+\|-+$//g' \
echo "$1" \
| tr "[:upper:]" "[:lower:]" \
| sed -r 's#refs/.*/##;s/[~\^]+//g;s/[^a-zA-Z0-9]+/-/g;s/^-+\|-+$//g;s/^-*//;s/-*$//' \
| cut -c1-63
}
echo ::set-env name=GITHUB_REF_SLUG::$(slug_ref $GITHUB_REF)
echo ::set-env name=GITHUB_HEAD_REF_SLUG::$(slug_ref $GITHUB_HEAD_REF)
echo ::set-env name=GITHUB_BASE_REF_SLUG::$(slug_ref $GITHUB_BASE_REF)
echo ::set-env name=GITHUB_REF_SLUG::"$(slug_ref "$GITHUB_REF")"
echo ::set-env name=GITHUB_HEAD_REF_SLUG::"$(slug_ref "$GITHUB_HEAD_REF")"
echo ::set-env name=GITHUB_BASE_REF_SLUG::"$(slug_ref "$GITHUB_BASE_REF")"