agent-starter-pack icon indicating copy to clipboard operation
agent-starter-pack copied to clipboard

Fix: Add .env file loading support for make deploy

Open sarojrout opened this issue 1 month ago • 3 comments

Fixes #545

This change adds automatic loading of environment variables from .env files during deployment for both Cloud Run and Agent Engine targets.

Changes:

  • Cloud Run: Makefile now loads .env file and merges variables with default deployment variables before passing to gcloud deploy
  • Agent Engine: deploy.py now includes load_env_file() function that parses .env files and merges with CLI-provided variables
  • Documentation: Updated deployment guide to document .env file support

The implementation:

  • Automatically detects .env file in project root
  • Parses KEY=VALUE pairs (ignoring comments and empty lines)
  • Merges .env variables with default deployment variables
  • CLI-provided variables take precedence over .env values
  • Fully backward compatible (works without .env file)

Tested with test project to verify parsing and merging works correctly.

sarojrout avatar Nov 27 '25 02:11 sarojrout

Summary of Changes

Hello @sarojrout, I'm Gemini Code Assist[^1]! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly enhances the deployment process for both Cloud Run and Agent Engine targets by introducing automatic loading of environment variables from .env files. This change streamlines configuration management, allowing developers to define environment-specific settings in a standard .env file, which is then seamlessly integrated into the deployment process. The implementation ensures backward compatibility and proper variable precedence, improving the overall developer experience for managing deployment configurations.

Highlights

  • Cloud Run Deployment: The make deploy command for Cloud Run now automatically loads environment variables from a .env file in the project root, merging them with default deployment variables before passing them to gcloud deploy.
  • Agent Engine Deployment: The deploy.py script for Agent Engine now includes a load_env_file() function to parse .env files, merging them with CLI-provided variables, where CLI inputs take precedence.
  • Documentation Update: The deployment guide has been updated to reflect and explain the new .env file loading support for both Cloud Run and Agent Engine deployment targets.
  • Variable Precedence: CLI-provided environment variables will always take precedence over those loaded from the .env file, ensuring explicit overrides are respected.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with :thumbsup: and :thumbsdown: on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

[^1]: Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

gemini-code-assist[bot] avatar Nov 27 '25 02:11 gemini-code-assist[bot]

Thanks for your contribution! On Cloud Run side, .env files should be already auto loaded by ADK Server. Do you not find this working?

eliasecchig avatar Nov 27 '25 11:11 eliasecchig

Raised and merged this to fill the gap on Agent Engine, please let me know if it looks good!

https://github.com/GoogleCloudPlatform/agent-starter-pack/pull/552

eliasecchig avatar Nov 27 '25 11:11 eliasecchig