Skip to content

Commit 2b92cb0

Browse files
committed
♻️ Simplify Copier environment configuration
1 parent 0625bcc commit 2b92cb0

4 files changed

Lines changed: 21 additions & 28 deletions

File tree

.copier/update_dotenv.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,20 @@
99
answers = json.loads(answers_path.read_text())
1010
env_path = root_path / ".env"
1111
env_content = env_path.read_text()
12+
# Keep deployment provider settings from replacing local development defaults.
13+
env_answer_keys = {
14+
"emails_from_email",
15+
"first_superuser",
16+
"first_superuser_password",
17+
"postgres_password",
18+
"project_name",
19+
"secret_key",
20+
}
1221
lines = []
1322
for line in env_content.splitlines():
1423
for key, value in answers.items():
24+
if key not in env_answer_keys:
25+
continue
1526
upper_key = key.upper()
1627
if line.startswith(f"{upper_key}="):
1728
if " " in value:

README.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,12 +199,8 @@ The input variables, with their default values (some auto generated) are:
199199
- `secret_key`: (default: `"changethis"`) The secret key for the project, used for security, stored in .env, you can generate one with the method above.
200200
- `first_superuser`: (default: `"admin@example.com"`) The email of the first superuser (in .env).
201201
- `first_superuser_password`: (default: `"changethis"`) The password of the first superuser (in .env).
202-
- `smtp_host`: (default: "") The SMTP server host to send emails, you can set it later in .env.
203-
- `smtp_user`: (default: "") The SMTP server user to send emails, you can set it later in .env.
204-
- `smtp_password`: (default: "") The SMTP server password to send emails, you can set it later in .env.
205202
- `emails_from_email`: (default: `"info@example.com"`) The email account to send emails from, you can set it later in .env.
206203
- `postgres_password`: (default: `"changethis"`) The password for the PostgreSQL database, stored in .env, you can generate one with the method above.
207-
- `sentry_dsn`: (default: "") The DSN for Sentry, if you are using it, you can set it later in .env.
208204

209205
## Backend Development
210206

copier.yml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,6 @@ first_superuser_password:
2121
help: The password of the first superuser (in .env)
2222
default: changethis
2323

24-
smtp_host:
25-
type: str
26-
help: The SMTP server host to send emails, you can set it later in .env
27-
default: ""
28-
29-
smtp_user:
30-
type: str
31-
help: The SMTP server user to send emails, you can set it later in .env
32-
default: ""
33-
34-
smtp_password:
35-
type: str
36-
help: The SMTP server password to send emails, you can set it later in .env
37-
default: ""
38-
3924
emails_from_email:
4025
type: str
4126
help: The email account to send emails from, you can set it later in .env
@@ -49,11 +34,6 @@ postgres_password:
4934
python -c "import secrets; print(secrets.token_urlsafe(32))"'
5035
default: changethis
5136

52-
sentry_dsn:
53-
type: str
54-
help: The DSN for Sentry, if you are using it, you can set it later in .env
55-
default: ""
56-
5737
_exclude:
5838
# Global
5939
- .vscode

deployment.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -200,16 +200,22 @@ To configure them, go to your repository's **Settings** > **Environments** and c
200200

201201
For each GitHub Environment (`staging` and `production`), configure the required secrets as [environment secrets](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets#creating-secrets-for-an-environment). Environment secrets are preferred over [repository secrets](https://docs.github.com/en/actions/how-tos/write-workflows/choose-what-workflows-do/use-secrets#creating-secrets-for-a-repository) because they are scoped to the specific environment, reducing exposure and aligning with any protection rules you configure.
202202

203-
The current Github Actions workflows expect these secrets:
203+
The deployment workflows require these secrets:
204204

205205
* `DOMAIN`
206-
* `EMAILS_FROM_EMAIL`
207206
* `FIRST_SUPERUSER`
208207
* `FIRST_SUPERUSER_PASSWORD`
209208
* `POSTGRES_PASSWORD`
210209
* `SECRET_KEY`
211-
* `LATEST_CHANGES`
212-
* `SMOKESHOW_AUTH_KEY`
210+
211+
To enable emails, configure these additional secrets with the values from your email provider:
212+
213+
* `SMTP_HOST`
214+
* `SMTP_USER`
215+
* `SMTP_PASSWORD`
216+
* `EMAILS_FROM_EMAIL`
217+
218+
To enable Sentry, configure the `SENTRY_DSN` secret.
213219

214220
## GitHub Action Deployment Workflows
215221

0 commit comments

Comments
 (0)