mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-06-13 01:51:09 +00:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e461860662 | ||
|
|
be6ec48344 | ||
|
|
93d0a6d6be |
@@ -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 }}
|
||||||
|
|||||||
@@ -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")"
|
||||||
|
|||||||
Reference in New Issue
Block a user