Skip to content
This repository was archived by the owner on Dec 10, 2025. It is now read-only.

Commit 6ea7cd4

Browse files
committed
update gitignore
1 parent 57b103c commit 6ea7cd4

File tree

5 files changed

+227
-75
lines changed

5 files changed

+227
-75
lines changed

examples-copier/.gitignore

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,23 @@ vendor/
2020
# Go workspace file
2121
go.work
2222

23-
# Environment files with secrets
23+
# Environment files with secrets (working files - create from templates in configs/)
24+
# Working files (create from templates):
25+
# env.yaml - App Engine deployment config (from configs/env.yaml.*)
26+
# env-cloudrun.yaml - Cloud Run deployment config (from configs/env.yaml.*)
27+
# .env - Local development config (from configs/.env.local.example)
2428
env.yaml
29+
env-cloudrun.yaml
2530
.env
2631
.env.local
2732
.env.production
2833
.env.*.local
2934

35+
# Explicitly keep template files in configs/ directory (these should be tracked)
36+
!configs/env.yaml.example
37+
!configs/env.yaml.production
38+
!configs/.env.local.example
39+
3040
# Private keys
3141
*.pem
3242
*.key

examples-copier/configs/README.md

Lines changed: 78 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,17 @@
1-
# Environment Files Comparison
1+
# Environment Configuration Guide
22

3-
Overview of the different environment configuration files and when to use each.
3+
This directory contains **template files** for different deployment scenarios. Copy the appropriate template to create your working configuration file.
44

5-
## Files Overview
5+
## Template Files Overview
66

7-
| File | Purpose | Use Case |
7+
| Template File | Purpose | Use Case |
88
|-----------------------|---------------------------------------|---------------------------------|
99
| `env.yaml.example` | Complete reference with all variables | First-time setup, documentation |
1010
| `env.yaml.production` | Production-ready template | Quick deployment to production |
1111
| `.env.local.example` | Local development template | Local testing and development |
1212

13+
**Note:** Your actual working files (`env.yaml`, `.env`) should be created from these templates and are gitignored to protect secrets.
14+
1315
---
1416

1517
## env.yaml.example
@@ -99,6 +101,54 @@ env_variables:
99101
100102
---
101103
104+
## Deployment Targets
105+
106+
This service supports **two Google Cloud deployment options**:
107+
108+
### App Engine (Flexible Environment)
109+
110+
**Config file:** `env.yaml` (with `env_variables:` wrapper)
111+
112+
**Format:**
113+
```yaml
114+
env_variables:
115+
GITHUB_APP_ID: "123456"
116+
REPO_OWNER: "mongodb"
117+
```
118+
119+
**Deploy:**
120+
```bash
121+
cp configs/env.yaml.production env.yaml
122+
# Edit env.yaml with your values
123+
gcloud app deploy app.yaml # Includes env.yaml automatically
124+
```
125+
126+
**Best for:** Long-running services, always-on applications
127+
128+
---
129+
130+
### Cloud Run (Serverless Containers)
131+
132+
**Config file:** `env-cloudrun.yaml` (plain YAML, no wrapper)
133+
134+
**Format:**
135+
```yaml
136+
GITHUB_APP_ID: "123456"
137+
REPO_OWNER: "mongodb"
138+
```
139+
140+
**Deploy:**
141+
```bash
142+
cp configs/env.yaml.production env-cloudrun.yaml
143+
# Remove the 'env_variables:' wrapper
144+
# Edit env-cloudrun.yaml with your values
145+
gcloud run deploy examples-copier --source . --env-vars-file=env-cloudrun.yaml
146+
```
147+
148+
**Best for:** Cost-effective, scales to zero, serverless
149+
150+
---
151+
102152
## Usage Scenarios
103153

104154
### Scenario 1: First-Time Production Deployment
@@ -196,6 +246,22 @@ env_variables:
196246
REPO_OWNER: "mongodb"
197247
```
198248

249+
### Between App Engine and Cloud Run formats
250+
251+
Use the format conversion script:
252+
253+
```bash
254+
# Convert App Engine → Cloud Run
255+
./scripts/convert-env-format.sh to-cloudrun env.yaml env-cloudrun.yaml
256+
257+
# Convert Cloud Run → App Engine
258+
./scripts/convert-env-format.sh to-appengine env-cloudrun.yaml env.yaml
259+
```
260+
261+
**Key difference:**
262+
- **App Engine**: Requires `env_variables:` wrapper with 2-space indentation
263+
- **Cloud Run**: Plain YAML without wrapper
264+
199265
### From env.yaml.production to env.yaml.example
200266

201267
```bash
@@ -238,10 +304,16 @@ examples-copier/
238304
│ ├── env.yaml.example # ← Complete reference (all variables)
239305
│ ├── env.yaml.production # ← Production template (essential only)
240306
│ └── .env.local.example # ← Local development template
241-
├── env.yaml # ← Your actual config (gitignored)
242-
└── .env # ← Your local config (gitignored)
307+
├── env.yaml # ← App Engine config (create from template, gitignored)
308+
├── env-cloudrun.yaml # ← Cloud Run config (create from template, gitignored)
309+
└── .env # ← Local config (create from template, gitignored)
243310
```
244311
312+
**Working files (not in repo):**
313+
- `env.yaml` - App Engine deployment (YAML with `env_variables:` wrapper)
314+
- `env-cloudrun.yaml` - Cloud Run deployment (plain YAML, no wrapper)
315+
- `.env` - Local development (KEY=value format)
316+
245317
---
246318
247319
## Quick Reference

examples-copier/env-cloudrun.yaml

Lines changed: 0 additions & 68 deletions
This file was deleted.

examples-copier/scripts/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,43 @@ Test 5: Sending deprecation notification...
142142
Check your Slack channel for 5 test notifications
143143
```
144144

145+
### convert-env-format.sh
146+
147+
Convert between App Engine and Cloud Run environment file formats.
148+
149+
**Usage:**
150+
```bash
151+
./scripts/convert-env-format.sh to-cloudrun <input> <output>
152+
./scripts/convert-env-format.sh to-appengine <input> <output>
153+
```
154+
155+
**What it does:**
156+
- Converts between App Engine format (with `env_variables:` wrapper) and Cloud Run format (plain YAML)
157+
- Handles indentation automatically
158+
- Validates input file exists
159+
- Prompts before overwriting existing files
160+
161+
**Example:**
162+
```bash
163+
# Convert App Engine → Cloud Run
164+
./scripts/convert-env-format.sh to-cloudrun env.yaml env-cloudrun.yaml
165+
166+
# Convert Cloud Run → App Engine
167+
./scripts/convert-env-format.sh to-appengine env-cloudrun.yaml env.yaml
168+
```
169+
170+
**Format differences:**
171+
```yaml
172+
# App Engine format (env.yaml)
173+
env_variables:
174+
GITHUB_APP_ID: "123456"
175+
REPO_OWNER: "mongodb"
176+
177+
# Cloud Run format (env-cloudrun.yaml)
178+
GITHUB_APP_ID: "123456"
179+
REPO_OWNER: "mongodb"
180+
```
181+
145182
### test-with-pr.sh
146183
147184
Fetch real PR data from GitHub and send it to the webhook.
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
#!/bin/bash
2+
3+
# Convert between App Engine (env.yaml) and Cloud Run (env-cloudrun.yaml) formats
4+
#
5+
# Usage:
6+
# ./convert-env-format.sh to-cloudrun env.yaml env-cloudrun.yaml
7+
# ./convert-env-format.sh to-appengine env-cloudrun.yaml env.yaml
8+
9+
set -e
10+
11+
# Colors for output
12+
RED='\033[0;31m'
13+
GREEN='\033[0;32m'
14+
BLUE='\033[0;34m'
15+
YELLOW='\033[1;33m'
16+
NC='\033[0m' # No Color
17+
18+
# Print usage
19+
usage() {
20+
echo "Convert between App Engine and Cloud Run environment file formats"
21+
echo ""
22+
echo "Usage:"
23+
echo " $0 to-cloudrun <input-env.yaml> <output-env-cloudrun.yaml>"
24+
echo " $0 to-appengine <input-env-cloudrun.yaml> <output-env.yaml>"
25+
echo ""
26+
echo "Examples:"
27+
echo " # Convert App Engine format to Cloud Run format"
28+
echo " $0 to-cloudrun env.yaml env-cloudrun.yaml"
29+
echo ""
30+
echo " # Convert Cloud Run format to App Engine format"
31+
echo " $0 to-appengine env-cloudrun.yaml env.yaml"
32+
echo ""
33+
echo "Formats:"
34+
echo " App Engine: env_variables: wrapper with indented keys"
35+
echo " Cloud Run: Plain YAML without wrapper"
36+
exit 1
37+
}
38+
39+
# Check arguments
40+
if [ $# -ne 3 ]; then
41+
usage
42+
fi
43+
44+
COMMAND=$1
45+
INPUT=$2
46+
OUTPUT=$3
47+
48+
# Validate command
49+
if [ "$COMMAND" != "to-cloudrun" ] && [ "$COMMAND" != "to-appengine" ]; then
50+
echo -e "${RED}Error: Invalid command '$COMMAND'${NC}"
51+
echo "Must be 'to-cloudrun' or 'to-appengine'"
52+
usage
53+
fi
54+
55+
# Check input file exists
56+
if [ ! -f "$INPUT" ]; then
57+
echo -e "${RED}Error: Input file '$INPUT' not found${NC}"
58+
exit 1
59+
fi
60+
61+
# Check if output file exists
62+
if [ -f "$OUTPUT" ]; then
63+
echo -e "${YELLOW}Warning: Output file '$OUTPUT' already exists${NC}"
64+
read -p "Overwrite? (y/N) " -n 1 -r
65+
echo
66+
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
67+
echo "Aborted"
68+
exit 1
69+
fi
70+
fi
71+
72+
# Convert to Cloud Run format (remove env_variables wrapper and unindent)
73+
if [ "$COMMAND" = "to-cloudrun" ]; then
74+
echo -e "${BLUE}Converting App Engine format to Cloud Run format...${NC}"
75+
76+
# Remove 'env_variables:' line and unindent by 2 spaces
77+
sed '/^env_variables:/d' "$INPUT" | sed 's/^ //' > "$OUTPUT"
78+
79+
echo -e "${GREEN}✓ Converted to Cloud Run format: $OUTPUT${NC}"
80+
echo ""
81+
echo "Deploy with:"
82+
echo " gcloud run deploy examples-copier --source . --env-vars-file=$OUTPUT"
83+
fi
84+
85+
# Convert to App Engine format (add env_variables wrapper and indent)
86+
if [ "$COMMAND" = "to-appengine" ]; then
87+
echo -e "${BLUE}Converting Cloud Run format to App Engine format...${NC}"
88+
89+
# Add 'env_variables:' header and indent all lines by 2 spaces
90+
echo "env_variables:" > "$OUTPUT"
91+
sed 's/^/ /' "$INPUT" >> "$OUTPUT"
92+
93+
echo -e "${GREEN}✓ Converted to App Engine format: $OUTPUT${NC}"
94+
echo ""
95+
echo "Deploy with:"
96+
echo " gcloud app deploy app.yaml # Includes $OUTPUT automatically"
97+
fi
98+
99+
echo ""
100+
echo -e "${YELLOW}Note: Review the output file before deploying!${NC}"
101+

0 commit comments

Comments
 (0)