I am new to GitHub Actions.
I am trying to deploy Python FastAPI with SQLAlchemy and Alembic for database migration on GCP with App Engine and SQL Postgres.
My problem is with getting secrets with the DB connection string inserted into env.py files. Here is my set-up:
- Github action secrets: DEV_DATABASE_URL: 'postgres+pg8000://....'
- Workflow YML file:
- name: Run Alembic migrations
run: alembic upgrade head
env:
DATABASE_URL: ${{ secrets.DEV_DATABASE_URL }}
- Alembic.ini file:
dotenv_config = dotenv_values(".env")
connection_string = dotenv_config["DATABASE_URL"]
Error, I am getting
connection_string = dotenv_config["DATABASE_URL"]
KeyError: 'DATABASE_URL'
I dont think your yaml creates a .env file. try this in Alembic.ini
if you have multiple variables