Closed razor-x closed 9 years ago
If anyone is curious, I am using the following to achieve this:
t.skip_commit = -> {
ENV['TRAVIS_PULL_REQUEST'].to_i > 0 ||
%w[yes y true 1].include?(ENV['SKIP_COMMIT'].to_s.downcase) ||
(!ENV['SOURCE_BRANCH'].nil? && ENV['SOURCE_BRANCH'] != ENV['TRAVIS_BRANCH'])
}
Feel free to make this the default or just close the issue if you don't want to implement. :smile:
I would like to understand your use case, but I still can’t imagine any situation where this may be useful. Could you please give me some example?
@jirutka Sure, the basic idea is that you have a repo for your site and each branch should benefit from normal CI testing, but only one branch should ever push to gh-pages
.
For example, by setting SOURCE_BRANCH=production
, I am free to branch without worry I will ever change the live site unless I push to production
, but I still get Travis to check if my branch is building without error. Also I don't have to encode this info in the actual source code where I don't think it belongs.
Ah, now I get it. I’m using this approach instead:
script: |
if [[ "$TRAVIS_BRANCH" == pages-src ]]; then
bundle exec rake deploy
fi
However, I like your suggestion, so I’m gonna implement it.
Say I want my branches to benefit from Travis CI but not actually deploy the site. I could configure in
.travis.yml
to build all branches exceptgh-pages
. Then I can set a Travis environment variableSOURCE_BRANCH
which sets the name of the only branch that should acually get pushed togh-pages
. I realize this could be customized inskip_commit
, however maybe you would consider adding it as part of the default.Another way to do this would be to add this as an option for the task itself, say
t.source_branch = ENV['SOURCE_BRANCH']
which would be empty by default. Then people could set it in theRakefile
or.travis.yml
or directly via Travis's interface.