Evan Benn
Evan Benn

Reputation: 1699

Travis CI to modify same branch

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?

Upvotes: 1

Views: 101

Answers (1)

Maël Pedretti
Maël Pedretti

Reputation: 784

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.

Upvotes: 1

Related Questions