I have an Android project that need token key which I store in a public repo. I do not commit my key to the repo. I integrate my repo with Travis CI for automated build. But, the building process will be failed because no token key is found. How should I provide the key to the CI without committing it to the repo?
Travis allows you to store encrypted environment variables for precisely this scenario. See here:
Encrypting environment variables
Encrypt environment variables with the public key attached to your repository using the
travis
gem:
If you do not have the
travis
gem installed, rungem install travis
.In your repository directory, run:
travis encrypt MY_SECRET_ENV=super_secret --add env.matrix
Commit the changes to your
.travis.yml
.Encryption and decryption keys are tied to the repository. If you fork a project and add it to Travis CI, it will not access to the encrypted variables.
The encryption scheme is explained in more detail in Encryption keys.