Only run CI when relevant files have changed

If nothing outside of the site directory was modified, don't run `make
ci`.

Signed-off-by: Nolan Brubaker <brubakern@vmware.com>
pull/1506/head
Nolan Brubaker 2019-05-20 13:13:18 -04:00
parent 029cee6bc3
commit 81287e4751
2 changed files with 18 additions and 1 deletions

View File

@ -8,4 +8,4 @@ sudo: required
services:
- docker
script: make ci
script: hack/ci-check.sh

17
hack/ci-check.sh Executable file
View File

@ -0,0 +1,17 @@
#!/usr/bin/env bash
# If we're doing push build, as opposed to a PR, always run make ci
if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then
make ci
# Exit script early, returning make ci's error
exit $?
fi
# Only run `make ci` if files outside of the site directory changed in the branch
# In a PR build, $TRAVIS_BRANCH is the destination branch.
if [[ $(git diff --name-only $TRAVIS_BRANCH | grep --invert-match site/) ]]; then
make ci
else
echo "Skipping make ci since nothing outside of site directory changed."
exit 0
fi