Home > Blockchain >  Rails Master Key on GitHub Actions causes ActiveSupport::MessageEncryptor::InvalidMessage
Rails Master Key on GitHub Actions causes ActiveSupport::MessageEncryptor::InvalidMessage

Time:07-19

Anyone have experience with using RAILS_MASTER_KEY env with GH Actions? Recently switched to Rails 7 from 6. Using the credentials.yml.enc to store the ActiveRecord encryption stuff. Have set RAILS_MASTER_KEY locally and it works fine. Have confirmed I can encode/decode stuff fine. However when pushing to GH and using our CI (running tests etc.) I come across this error:

ActiveSupport::MessageEncryptor::InvalidMessage: ActiveSupport::MessageEncryptor::InvalidMessage
Caused by:
OpenSSL::Cipher::CipherError: 

I have added the ENV to the GH Action but still no dice:

RAILS_MASTER_KEY=${{ secrets.RAILS_MASTER_KEY }}

Then I set the secret in the repo as well, it seems it is not reading it correctly?

CodePudding user response:

The fix I found for this was adding the following to test.rb inside config/environments

  config.active_record.encryption.primary_key = "test"
  config.active_record.encryption.deterministic_key = "test"
  config.active_record.encryption.key_derivation_salt = "test"
  • Related