Fix SLUG and TYPE for GitHub Actions

This commit is contained in:
cytopia
2020-11-29 13:38:54 +01:00
parent abd10c104b
commit 30f18d858e
2 changed files with 36 additions and 16 deletions

View File

@@ -93,14 +93,24 @@ jobs:
- name: Set variables
id: vars
run: |
# Detached from branch
if [ "$( git rev-parse --abbrev-ref HEAD )" = "HEAD" ]; then
GIT_TYPE=TAG
GIT_SLUG="$( git tag --points-at HEAD | head -1 )"
else
GIT_TYPE=BRANCH
GIT_SLUG="$( git rev-parse --abbrev-ref HEAD )"
fi
# Retrieve git info (tags, etc)
git fetch --all
# BRANCH, TAG or COMMIT
GIT_TYPE="$( \
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
| sh \
| grep '^GIT_TYPE' \
| sed 's|.*=||g' \
)"
# Branch name, Tag name or Commit Hash
GIT_SLUG="$( \
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
| sh \
| grep '^GIT_NAME' \
| sed 's|.*=||g' \
)"
# Output
echo "GIT_TYPE=${GIT_TYPE}"

View File

@@ -97,14 +97,24 @@ jobs:
- name: Set variables
id: vars
run: |
# Detached from branch
if [ "$( git rev-parse --abbrev-ref HEAD )" = "HEAD" ]; then
GIT_TYPE=TAG
GIT_SLUG="$( git tag --points-at HEAD | head -1 )"
else
GIT_TYPE=BRANCH
GIT_SLUG="$( git rev-parse --abbrev-ref HEAD )"
fi
# Retrieve git info (tags, etc)
git fetch --all
# BRANCH, TAG or COMMIT
GIT_TYPE="$( \
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
| sh \
| grep '^GIT_TYPE' \
| sed 's|.*=||g' \
)"
# Branch name, Tag name or Commit Hash
GIT_SLUG="$( \
curl -sS https://raw.githubusercontent.com/cytopia/git-tools/master/git-info.sh \
| sh \
| grep '^GIT_NAME' \
| sed 's|.*=||g' \
)"
# Output
echo "GIT_TYPE=${GIT_TYPE}"