One cool idea to handle .env files:
https://github.com/tiangolo/full-stack-fastapi-template/issues/724#issuecomment-1999566151
Step 1: Encode the .env
File
You can encode your .env
file to a base64 string using a command-line tool like base64
:
Step 2: Store the Encoded String in GitHub Secrets
- Go to your GitHub repository.
- Navigate to Settings > Secrets > Actions.
- Click on New repository secret.
- Name your secret (e.g.,
ENCODED_ENV
) and paste the content of.env.base64
.
Step 3: Modify GitHub Actions to Decode and Use the .env
File
In your GitHub Actions workflow, you can add steps to decode the base64 string and create an .env
file during the build or deployment process:
I am going to give a try, it can further be streamlined through a git pre-commit hook to always encode and keep the latest .env variables into repo