Travis CI to modify same branch

Evan Benn

I want to use travis-ci to run a script and commit the result back to the same branch on github. (The script generates a markdown table of contents, but could be anything really). Obviously this causes an issue as travis will then see a new commit and run again ad infinitum. I tried to use

if: sender != "Travis CI"

In my .travis.yml, but the docs are extremely vague about what exactly 'sender' is matching against, and I see no way to inspect the run time values travis is using.

I use this method: https://gist.github.com/willprice/e07efd73fb7f13f917ea to commit back to github.

Is there a better way to achieve what I want? Or what is the correct way to make this work with travis?

Maël Pedretti

There might cleaner ways of doing it but one way is to use the following.

According to this documentation, you can simply add a "tag" or specific string to your commit message in order to avoid Travis building it.

Simply add [ci skip] or [skip ci] to your commit message and Travis will ignore it.

Your function in push.sh will become the following:

commit_website_files() {
  git checkout -b gh-pages
  git add . *.html
  git commit --message "[skip cp] Travis build: $TRAVIS_BUILD_NUMBER"
}

Also you could still push to another branch which wouldn't be watched by Travis.

Hope this helps.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related