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

View File

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