mirror of
https://github.com/oh-my-fish/oh-my-fish
synced 2024-11-03 15:40:32 +00:00
Get PR URL and Branch using GitHub API
This commit is contained in:
parent
e40f2d3ceb
commit
0b2a51a93f
@ -9,7 +9,7 @@ env:
|
||||
- OMF_REPO_BRANCH="$TRAVIS_BRANCH"
|
||||
|
||||
before_install:
|
||||
- export OMF_REPO_BRANCH=`tools/branch-name.sh`
|
||||
- source tools/travis-github-pr-integration.sh
|
||||
- docker build -t fish . < Dockerfile
|
||||
|
||||
before_script:
|
||||
|
@ -1,16 +0,0 @@
|
||||
#!/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
|
13
tools/travis-github-pr-integration.sh
Executable file
13
tools/travis-github-pr-integration.sh
Executable file
@ -0,0 +1,13 @@
|
||||
# Return if we are not in a Pull Request
|
||||
[[ "$TRAVIS_PULL_REQUEST" = "false" ]] && return
|
||||
|
||||
GITHUB_PR_URL=https://api.github.com/repos/$TRAVIS_REPO_SLUG/pulls/$TRAVIS_PULL_REQUEST
|
||||
GITHUB_PR_BODY=$(curl -s $GITHUB_PR_URL 2>/dev/null)
|
||||
|
||||
if [[ $GITHUB_PR_BODY =~ \"ref\":\ *\"([a-zA-Z0-9_-]*)\" ]]; then
|
||||
export OMF_REPO_BRANCH=${BASH_REMATCH[1]}
|
||||
fi
|
||||
|
||||
if [[ $GITHUB_PR_BODY =~ \"repo\":.*\"clone_url\":\ *\"(https://github\.com/[a-zA-Z0-9_-]*/[a-zA-Z0-9_-]*\.git).*\"base\" ]]; then
|
||||
export OMF_REPO_URI=${BASH_REMATCH[1]}
|
||||
fi
|
Loading…
Reference in New Issue
Block a user