Question

How to pass env variable within django app to digitalocean droplet

Hi there, I have deployed a django app using this tutorial:

https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04#create-and-configure-a-new-django-project

Now i want to create env variables for secret keys and api tokens. The problems is, i deploy my app through github and if i add .env to gitignore it will not be pulled to the droplet. And if i dont add gitignore, the will no point to create .env

So how can i pass .env file to droplet through github (I want to make the repo public)

Thank you in advance :)


Submit an answer
Answer a question...

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Bobby Iliev
Site Moderator
Site Moderator badge
June 26, 2022

Hi there,

You could add your environment variables as secrets to your GitHub repository and then pass them over to your GitHub actions as described here in the docs:

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

That way you will not have to commit your secrets directly.

Let me know how it goes!

Best,

Bobby