Created
June 4, 2020 22:56
-
-
Save nashmaniac/6e00264a1e444c049c4086c0c055ed6c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Why this block? | |
GITHUB_WORKFLOW env variable is only available in GitHub Actions. So in actions | |
we want a simple postgres docker image to be booted as a service and does all the testing there. | |
When we deploy to cloud the else block will work as we won't be having GITHUB_WORKFLOW env var in our deployment. | |
That time the db config we use DB_USER, DB_NAME, DB_PASSWORD, DB_HOST and DB_PASSWORD | |
which we will set in repository secret to be used in our deployment. | |
''' | |
if os.getenv('GITHUB_WORKFLOW'): | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.postgresql', | |
'NAME': 'github-actions', | |
'USER': 'postgres', | |
'PASSWORD': 'postgres', | |
'HOST': 'localhost', | |
'PORT': '5432' | |
} | |
} | |
else: | |
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.postgresql', | |
'NAME': os.getenv('DB_NAME'), | |
'USER': os.getenv('DB_USER'), | |
'PASSWORD': os.getenv('DB_PASSWORD'), | |
'HOST': os.getenv('DB_HOST'), | |
'PORT': os.getenv('DB_PORT') | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment