简体   繁体   中英

Rails & Github Actions - Credentials

I have a Rails 6 app using the credentials storage built into Rails and I am running testing and CI on this app with Github Actions.

I have initializer code that uses credentials that passes test on my local machine because it uses credentials from config/credentials/test.yml.enc , however Actions can't access this file. I have seen suggestions online to set RAILS_MASTER_KEY as an environment variable with the key value from the credential key file, but I have set up RAILS_TEST_KEY (and RAILS_MASTER_KEY ) to be the value of config/credentials/test.key with no luck. Does Rails know to look for this environment variable if the key file isn't present, or do I need to do something to point it to this variable?

Apologies, if i didn't understand your question correctly. You can reference CI ENV variables using repository secrets. For example if you have ENV variable called RAILS_TEST_KEY in your CI yml file.

env:
 RAILS_TEST_KEY: ${{ secrets.RAILS_TEST_KEY }}

secrets.RAILS_TEST_KEY value can be set in repository secrets.

https://docs.github.com/en/actions/reference/encrypted-secrets

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM