From ca002654ee9a4e45b9632fb1d821a1eeb338c615 Mon Sep 17 00:00:00 2001 From: YeonJeong Kim Date: Wed, 25 Oct 2023 18:45:40 +0900 Subject: [PATCH] :wrench: Modify settings.py to get secret variables in CI --- backend/config/settings.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/backend/config/settings.py b/backend/config/settings.py index 4131164d..2bdee62c 100644 --- a/backend/config/settings.py +++ b/backend/config/settings.py @@ -26,11 +26,17 @@ # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/4.2/howto/deployment/checklist/ -# SECURITY WARNING: keep the secret key used in production secret! -secret_file = os.path.join(BASE_DIR, 'secrets.json') # secrets.json 파일 위치를 명시 - -with open(secret_file) as f: - secrets = json.loads(f.read()) +if "GITHUB_ACTIONS" in os.environ: + # If running in GitHub Actions, use secrets from environment variables + secrets = { + "SECRET_KEY": os.environ.get("SECRET_KEY"), + "EMAIL_HOST_USER": os.environ.get("EMAIL_HOST_USER"), + "EMAIL_HOST_PASSWORD": os.environ.get("EMAIL_HOST_PASSWORD"), + } +else: + secret_file = os.path.join(BASE_DIR, 'secrets.json') # secrets.json 파일 위치를 명시 + with open(secret_file) as f: + secrets = json.loads(f.read()) def get_secret(setting, secrets=secrets):