I am trying to set up gitlab.com continuous integration(CI) for one of my private projects. But rails db:migrate is failing with the following error:
ActiveSupport::EncryptedFile::MissingKeyError: Missing encryption key to decrypt file with. Ask your team for your master key and write it to /builds/shubh-muhurat/Backend/config/master.key or put it in the ENV['RAILS_MASTER_KEY']
The master key should not be there in the repository, but if I set RAILS_MASTER_KEY using .gitlab-ci.yml I have to commit the master key to the repository.
So is there a better way of putting the master key.
PS: I am using gitlab.com CI.
Version: Rails 5.2.0.beta2
I solved this by adding the master key to the projects secret variables and then injecting it during the before_script phase:
- echo "$MASTER_KEY" > config/master.key
After doing a bit of research for finding the easiest way of declaring the variables, I came across the Variables section in GitLab. The Variables section is located under the repository CI/CD setting. There is also an option of making your variables protected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With