mirror of
https://github.com/rlespinasse/github-slug-action.git
synced 2026-05-18 05:05:02 +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,
|
||||
- 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 }}
|
||||
|
||||
@@ -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")"
|
||||
|
||||
Reference in New Issue
Block a user