How to configure Travis-CI to build pull requests & merges to master w/o redundancy

前端 未结 6 450
一整个雨季
一整个雨季 2021-01-30 08:20

To put it in \"BDD\" terms:

Background:
Given I\'m contributing to a GH repo

When I create a pull request
Then Travis shou

6条回答
  •  失恋的感觉
    2021-01-30 08:36

    Assuming you want to build all PRs, something like the following will do the trick. Enable both branch and PR builds on the settings page, and put this line as the first line in your travis.yml:

    if: (type = push AND branch IN (master, dev)) OR (type = pull_request AND NOT branch =~ /no-ci/)

    This will attempt a push build on all pushes and a PR build on all pushes to an open PR, but will filter out any that don't meet the condition. You might need to modify this a bit - the clause about not building branches with no-ci somewhere in their name is obviously optional, and you may not have two branches that you always want to run builds on.

    You can read more on conditions and conditional builds on Travis's site.

提交回复
热议问题