Github actions failing with "OpenAI API key not set"
Tests work in development but failing in Github. Checking doc to determine how to safely provide keys.
4 Replies
Wohooo @Ghar, you just became a Waspeteer level 1!
Hi @Ghar. I'm kapa.ai, your friendly support bot. I will try to answer your question by searching through the knowledge base. :wave:
----------------------
The error message indicates that the
OPENAI_API_KEY
environment variable is not set. In Wasp, environment variables can be set in the .env.server
file at the root of your project.
Here is an example of how to set environment variables in Wasp:
Replace your-openai-api-key
with your actual OpenAI API key.
However, it's important to note that you should not commit sensitive data like API keys to your version control system. For GitHub Actions, you can set secrets in the repository settings. These secrets are encrypted and can be used in your GitHub Actions workflows.
Once you've set the OPENAI_API_KEY
secret in your GitHub repository settings, you can use it in your GitHub Actions workflow file like this:
This way, the OPENAI_API_KEY
environment variable will be available to your tests when they run in GitHub Actions.
Please note that the information provided is based on general knowledge and practices, as the provided knowledge sources do not contain specific information about setting environment variables in GitHub Actions for a Wasp project.
For more information on how to use secrets in GitHub Actions, you can refer to the GitHub Actions documentation (https://docs.github.com/en/actions/reference/encrypted-secrets).
----------------------
Note: you can ask me a follow up question by @ mentioning me again :speech_balloon:
----------------------
Sorry @Ghar, I seem to be having a bit of trouble. Don't worry though, I've pinged my support and they will try to fix me up! :technologist:
Perhaps try again in 15mins?Looks like the bot gave good tips. Did you get it working?
Yes perfect - added secrets to github repo.
Thanks for checking.