Saurabh Shah
Saurabh Shah

Reputation: 606

Failing Travis CI tests when using secret keys in rails

I am using environment variables in secrets.yml for production environment in my rails app. I am sending http post request with api key and password. I can pass my local tests in test environment by using the password. But my password can't be exposed, so how do I pass travis ci tests on github?

Upvotes: 1

Views: 454

Answers (1)

Deepak Mahakale
Deepak Mahakale

Reputation: 23711

You can encrypt your secrets.yml and push encrypted file to the repository.

travis encrypt-file secrets.yml

which will give you secrets.yml.enc add it to repository. Remember not to push secrets.yml.

You need to decrypt that file in before_script

before_script: openssl aes-256-cbc -K $encrypted_0a6446eb3ae3_key -iv $encrypted_0a6446eb3ae3_key -in secrets.yml.enc -out secrets.yml -d

You can directly add above command to travis.yml using --add option:

travis encrypt-file secrets.yml --add

Refer this documentation for more details - Encrypting Files in Travis

Upvotes: 1

Related Questions