mirror of
https://github.com/oh-my-fish/oh-my-fish
synced 2024-11-15 12:12:45 +00:00
Get original repository branch name
Travis does not provide the original repository branch name on any environment variable. We are getting the information from the GitHub API instead. The misleading environment variable `TRAVIS_BRANCH` returns `master` instead: > TRAVIS_BRANCH: For builds not triggered by a pull request this is the name of the branch currently being built; whereas for builds triggered by a pull request this is the name of the branch targeted by the pull request (in many cases this will be master). Reference: http://docs.travis-ci.com/user/environment-variables/
This commit is contained in:
parent
faba765a94
commit
dde679ff98
@ -9,6 +9,7 @@ env:
|
||||
- OMF_REPO_BRANCH="$TRAVIS_BRANCH"
|
||||
|
||||
before_install:
|
||||
- export OMF_REPO_BRANCH=`tools/branch-name.sh`
|
||||
- docker build -t fish . < Dockerfile
|
||||
|
||||
before_script:
|
||||
|
16
tools/branch-name.sh
Executable file
16
tools/branch-name.sh
Executable file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env sh
|
||||
|
||||
URL=https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST
|
||||
|
||||
BRANCH_NAME=`curl -s $URL ^/dev/null \
|
||||
| grep -C 2 "head" \
|
||||
| grep \"ref\" \
|
||||
| cut -d':' -f2- \
|
||||
| sed -e 's/["|,]//g;s/^[ \t]//g'
|
||||
`
|
||||
|
||||
if [ -n "$BRANCH_NAME" ]; then
|
||||
echo $BRANCH_NAME
|
||||
else
|
||||
echo $TRAVIS_BRANCH
|
||||
fi
|
Loading…
Reference in New Issue
Block a user