TRAVIS builds are triggered by every commit to the repository. When hosting github pages with the source (e.g. in the
docs folder), changes to the documentation are (usually) not critical to the build itself, so they could be easily skipped. Unfortunately TRAVIS does not offer a file-/foldername-based skip instruction like e.g. AppVeyor's
But there seem to be two ways of achieving (almost) the same effect. In the following examples changes to the files
.appveyor.yml .gitattributes .gitignore docs/**
should not trigger a TRAVIS build. The first way is using the
before_install instruction in
before_install: - | if ! git diff --name-only $TRAVIS_COMMIT_RANGE | grep -qvE '(^\.(git|appveyor))|(^(LICENSE|docs))' then echo "Only build non-relevant files were updated, not running the CI." exit fi
This will not stop TRAVIS from setting up the environment(!) but will exit the build before the install job is started.
To skip the job, one can also add
[skip ci] to the commit message. To automate this I've created the following hook
#!/bin/sh COMMIT_MSG_FILE=$1 COMMIT_SOURCE=$2 SHA1=$3 if git diff --cached --exit-code --name-only -- . ':(top,exclude)docs/' ':!\.git*' ':!\.appveyor.yml' #>/dev/null 2>&1 then /usr/bin/perl -i.bak -pe 'print "[skip travis] " if !$first_line++' "$COMMIT_MSG_FILE" fi
IMO the disadvanage here is, that this pollutes the git log.
The best solution would be, if TRAVIS could add support for something like the already mentioned
skip_commits instruction set.