Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Make Travis-CI push files to other repositories for you when tests pass
language: ruby
- 2.0.0
- USER="username"
- EMAIL=""
- REPO="name of target repo"
- FILES=" foo.txt bar.txt"
- GH_REPO="${USER}/${REPO}.git"
- secure: "put travis gem output here =>"
- ruby test.rb
- MESSAGE=$(git log --format=%B -n 1 $TRAVIS_COMMIT)
- git clone git://${GH_REPO}
- mv -f ${FILES} ${REPO}
- cd ${REPO}
- git remote
- git config ${EMAIL}
- git config ${USER}
- git add ${FILES}
- git commit -m ${MESSAGE}
- git push "https://${TRAVIS_SECURE_TOKEN_NAME}@${GH_REPO}" master > /dev/null 2>&1

Travis-CI tested push

Sometimes we have a private repository to hold both problems and solutions as a reference for the class projects. The students can see only the problems in a public repository where they are able to clone/fork and develop their own solutions. We do not want the solution files in the public repository and each bug found/feature added in the project requires a push for each repository. It would be cool to work only with the reference repo and use tests to see if our modification is good enough for the public release. This is possible with Travis-CI following simple steps:

  • Create private and public repos
  • Install Ruby
  • Install Travis gem gem install travis
  • Generate a token in the Github website to allow others to play with your repos (copy the hash)
  • Log into your git account
  • Generate a secure token with the Travis gem (copy long hash)
  • Fill the environment variables in the .travis.yml file (USER, EMAIL, REPO, FILES)
  • Replace the value of secure with your long hash
  • Replace TRAVIS_SECURE_TOKEN_NAME with your Travis token name
  • Push .travis.yml to private repo
  • Go to Travis to unlock your private repo tests
  • Push your files to the private repo to test

Travis now has a deployment feature, which may be better for certain scenarios.


This comment has been minimized.

Copy link

@avchugaev avchugaev commented Nov 11, 2018

Thank you. It works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment