Convert your local nao project into a Git repository for version control, collaboration, and automated deployments.
Why Use Git?
Using Git for your nao project provides:
- Version Control: Track changes to your context files
- Collaboration: Multiple team members can contribute
- Automated Sync: Use GitHub Actions to automatically sync context
- Deployment: Easy integration with cloud deployments (Cloud Run, etc.)
- Backup: Your context is safely stored in the cloud
Initial Setup
Step 1: Initialize Git Repository
Navigate to your nao project directory:
Initialize a Git repository:
Step 2: Create .gitignore
Create a .gitignore file to exclude sensitive files:
# Environment variables
.env
# Credentials (never commit these!)
credentials/
# Python
venv/
Never commit credentials or API keys to Git! Always use environment variables or secret management systems.
Update your nao_config.yaml to use environment variables instead of file paths:
Before (local files):
databases:
- name: bigquery-prod
type: bigquery
project_id: my-project
dataset_id: analytics
credentials_path: /path/to/credentials/key-file.json
After (environment variables):
databases:
- name: bigquery-prod
type: bigquery
project_id: my-project
dataset_id: analytics
credentials_json: {{ env('GCP_SERVICE_ACCOUNT_KEY_JSON') }}
Step 4: Add and Commit Files
Add your project files:
git add .
git commit -m "Initial nao project"
Step 5: Create GitHub Repository
- Go to GitHub and create a new repository
- Donβt initialize with README, .gitignore, or license (you already have these)
- Copy the repository URL
Step 6: Connect to GitHub
Add the remote and push:
git remote add origin https://github.com/your-username/your-repo.git
git branch -M main
git push -u origin main
Best Practices
1. Use Environment Variables
Always use environment variables for secrets:
# β
Good
credentials_json: {{ env('GCP_SERVICE_ACCOUNT_KEY_JSON') }}
api_key: ${OPENAI_API_KEY}
# β Bad - Never do this
credentials_path: ./credentials/key.json
api_key: sk-abc123...
2. Store Secrets Securely
For Local Development:
- Use
.env file (in .gitignore)
- Load with
source .env or a tool like direnv
For Cloud Deployments:
- Use secret management (Google Secret Manager, AWS Secrets Manager, etc.)
- Store in GitHub Secrets for Actions
For GitHub Actions:
- Go to repository Settings β Secrets and variables β Actions
- Add secrets for all credentials used in
nao_config.yaml
3. Commit Synced Context
After running nao sync, commit the generated context files:
nao sync
git add databases/ docs/ repos/
git commit -m "Update context from nao sync"
git push
4. Use Automated Sync
Set up GitHub Actions to automatically sync and commit context updates.
Deployment Integration
Cloud Run Deployment
When deploying to Cloud Run:
- Connect your GitHub repository to Cloud Build
- Cloud Build automatically builds and deploys on push
- Use Secret Manager for credentials
- Environment variables are set in Cloud Run configuration
See the Self-Hosting Guide for Cloud Run deployment details.
Dockerfile
Create a Dockerfile in your repository:
FROM getnao/nao:latest
# Copy your project
COPY . /app/project/
# Set working directory
WORKDIR /app/project
Create a .dockerignore:
.env
venv/
.git/
.gitignore
credentials/
Whatβs Next?