bhall2001 / serverless-nextjs-github-ci-cd

How to use Github actions to manage the CI/CD flow of a serverless-nextjs project.
MIT License
79 stars 11 forks source link

Environment Variables #5

Closed murtyjones closed 2 years ago

murtyjones commented 3 years ago

Thanks for this awesome guide!

Any idea how to inject environment variables with this type of a serverless setup? I'm finding it to be surprisingly hard without checking the variables into the repo.

fredfgb commented 3 years ago

I think the easiest way to use environment variables in this scenario is to create your secrets in your CICD pipeline, in my case I'm using github actions so you need to reference the secrets and export them as env variables in order to access at build time in nextjs

image

and in your serverless.yml file you need to reference those variables like this:

image

bhall2001 commented 2 years ago

Closing. comment above is proper way to handle environment variables.