-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: move branch name fetching to new script
Also properly detect injected branch name.
- Loading branch information
Jose Diaz-Gonzalez
committed
Dec 4, 2020
1 parent
9f67113
commit d3c7094
Showing
2 changed files
with
34 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/sh -l | ||
set -e | ||
|
||
value="$CI_BRANCH_NAME" | ||
if [ -n "$CI_BRANCH_NAME" ]; then | ||
true | ||
elif [ -n "$CI_COMMIT_REF_NAME" ]; then | ||
# gitlab-ci | ||
value="$CI_COMMIT_REF_NAME" | ||
elif [ -n "$GITHUB_REF" ]; then | ||
# github actions | ||
value="${GITHUB_REF#refs/heads/}" | ||
elif [ -n "$CIRCLE_BRANCH" ]; then | ||
# circleci | ||
value="$CIRCLE_BRANCH" | ||
elif [ -n "$TRAVIS_BRANCH" ]; then | ||
# travisci | ||
value="$TRAVIS_BRANCH" | ||
elif [ -n "$SEMAPHORE_GIT_BRANCH" ]; then | ||
# semaphoreci | ||
value="SEMAPHORE_GIT_BRANCH" | ||
elif [ -n "$CI_BRANCH" ]; then | ||
# cloudbees | ||
value="CI_BRANCH" | ||
elif [ -n "$DRONE_COMMIT_BRANCH" ]; then | ||
# drone | ||
value="DRONE_COMMIT_BRANCH" | ||
else | ||
exit 0 | ||
fi | ||
|
||
echo "$value" | tr '[:upper:]' '[:lower:]' | sed "s/[[:alpha:].-]/-/g" |