Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions examples-copier/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# Binaries
examples-copier
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool
*.out

# Dependency directories
vendor/

# Go workspace file
go.work

# Environment files with secrets
env.yaml
.env
.env.local
.env.production
.env.*.local

# Private keys
*.pem
*.key

# IDE files
.idea/
.vscode/
*.swp
*.swo
*~

# OS files
.DS_Store
Thumbs.db

# Logs
*.log

# Temporary files
tmp/
temp/

env.yaml
22 changes: 20 additions & 2 deletions examples-copier/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,16 @@ test-webhook:
# Test with example payload
test-webhook-example: test-webhook
@echo "Testing with example payload..."
@./test-webhook -payload test-payloads/example-pr-merged.json
@if [ -z "$$WEBHOOK_SECRET" ]; then \
echo "Fetching webhook secret from Secret Manager..."; \
export WEBHOOK_SECRET=$$(gcloud secrets versions access latest --secret=webhook-secret 2>/dev/null); \
fi; \
if [ -n "$$WEBHOOK_SECRET" ]; then \
./test-webhook -payload test-payloads/example-pr-merged.json -secret "$$WEBHOOK_SECRET"; \
else \
echo "Warning: WEBHOOK_SECRET not set, sending without signature"; \
./test-webhook -payload test-payloads/example-pr-merged.json; \
fi

# Test with real PR (requires PR, OWNER, REPO variables)
test-webhook-pr: test-webhook
Expand All @@ -69,7 +78,16 @@ test-webhook-pr: test-webhook
echo "Usage: make test-webhook-pr PR=123 OWNER=myorg REPO=myrepo"; \
exit 1; \
fi
@./test-webhook -pr $(PR) -owner $(OWNER) -repo $(REPO)
@if [ -z "$$WEBHOOK_SECRET" ]; then \
echo "Fetching webhook secret from Secret Manager..."; \
export WEBHOOK_SECRET=$$(gcloud secrets versions access latest --secret=webhook-secret 2>/dev/null); \
fi; \
if [ -n "$$WEBHOOK_SECRET" ]; then \
./test-webhook -pr $(PR) -owner $(OWNER) -repo $(REPO) -secret "$$WEBHOOK_SECRET"; \
else \
echo "Warning: WEBHOOK_SECRET not set, sending without signature"; \
./test-webhook -pr $(PR) -owner $(OWNER) -repo $(REPO); \
fi

# Test with real PR using helper script
test-pr:
Expand Down
27 changes: 26 additions & 1 deletion examples-copier/QUICK-REFERENCE.md
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,29 @@ curl http://localhost:8080/health
curl http://localhost:8080/metrics | jq
```

## Deployment

### Google Cloud Quick Commands

```bash
# Deploy (env.yaml is included via 'includes' directive in app.yaml)
gcloud app deploy app.yaml

# View logs
gcloud app logs tail -s default

# Check health
curl https://github-copy-code-examples.appspot.com/health

# List secrets
gcloud secrets list

# Grant access
./grant-secret-access.sh
```



## File Locations

```
Expand All @@ -390,7 +413,9 @@ examples-copier/
├── MIGRATION-GUIDE.md # Migration from legacy
├── QUICK-REFERENCE.md # This file
├── REFACTORING-SUMMARY.md # Feature details
├── DEPLOYMENT-GUIDE.md # Deployment instructions
├── docs/
│ ├── DEPLOYMENT.md # Deployment guide
│ └── DEPLOYMENT-CHECKLIST.md # Deployment checklist
├── TESTING-SUMMARY.md # Test documentation
├── configs/
│ ├── .env # Environment config
Expand Down
8 changes: 5 additions & 3 deletions examples-copier/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ GITHUB_INSTALLATION_ID=789012

# Google Cloud
GCP_PROJECT_ID=your-project
PEM_KEY_NAME=projects/123/secrets/CODE_COPIER_PEM/versions/latest
PEM_KEY_NAME=projects/123/secrets/<name>/versions/latest
WEBHOOK_SECRET_NAME=projects/123/secrets/webhook-secret

# Application Settings
PORT=8080
Expand Down Expand Up @@ -415,7 +416,7 @@ container := NewServiceContainer(config)

## Deployment

See [DEPLOYMENT-GUIDE.md](DEPLOYMENT-GUIDE.md) for complete deployment instructions.
See [DEPLOYMENT.md](./docs/DEPLOYMENT.md) for complete deployment guide and [DEPLOYMENT-CHECKLIST.md](./docs/DEPLOYMENT-CHECKLIST.md) for step-by-step checklist.

### Google Cloud App Engine

Expand Down Expand Up @@ -444,7 +445,8 @@ docker run -p 8080:8080 --env-file .env examples-copier
- **[Configuration Guide](docs/CONFIGURATION-GUIDE.md)** - Complete configuration reference ⭐ NEW
- **[Pattern Matching Guide](docs/PATTERN-MATCHING-GUIDE.md)** - Pattern matching with examples
- **[Local Testing](docs/LOCAL-TESTING.md)** - Test locally before deploying
- **[Deployment Guide](docs/DEPLOYMENT-GUIDE.md)** - Deploy to production
- **[Deployment Guide](docs/DEPLOYMENT.md)** - Deploy to production
- **[Deployment Checklist](docs/DEPLOYMENT-CHECKLIST.md)** - Step-by-step deployment checklist

### Reference

Expand Down
11 changes: 11 additions & 0 deletions examples-copier/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,17 @@ func main() {
os.Exit(1)
}

// Load secrets from Secret Manager if not directly provided
if err := services.LoadWebhookSecret(config); err != nil {
fmt.Printf("❌ Error loading webhook secret: %v\n", err)
os.Exit(1)
}

if err := services.LoadMongoURI(config); err != nil {
fmt.Printf("❌ Error loading MongoDB URI: %v\n", err)
os.Exit(1)
}

// Override dry-run from command line
if dryRun {
config.DryRun = true
Expand Down
3 changes: 3 additions & 0 deletions examples-copier/app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ runtime_config:
operating_system: "ubuntu22"
runtime_version: "1.23"
env: flex

includes:
- env.yaml
6 changes: 3 additions & 3 deletions examples-copier/cmd/test-webhook/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func main() {
prNumber := flag.Int("pr", 0, "PR number to fetch from GitHub")
owner := flag.String("owner", "", "Repository owner")
repo := flag.String("repo", "", "Repository name")
webhookURL := flag.String("url", "http://localhost:8080/webhook", "Webhook URL")
webhookURL := flag.String("url", "http://localhost:8080/events", "Webhook URL")
secret := flag.String("secret", "", "Webhook secret for signature")
payloadFile := flag.String("payload", "", "Path to custom payload JSON file")
dryRun := flag.Bool("dry-run", false, "Print payload without sending")
Expand Down Expand Up @@ -95,7 +95,7 @@ Options:
-pr int PR number to fetch from GitHub
-owner string Repository owner (required with -pr)
-repo string Repository name (required with -pr)
-url string Webhook URL (default: http://localhost:8080/webhook)
-url string Webhook URL (default: http://localhost:8080/events)
-secret string Webhook secret for HMAC signature
-payload string Path to custom payload JSON file
-dry-run Print payload without sending
Expand All @@ -117,7 +117,7 @@ Examples:

# Send to production with secret
test-webhook -pr 123 -owner myorg -repo myrepo \
-url https://myapp.appspot.com/webhook \
-url https://myapp.appspot.com/events \
-secret "my-webhook-secret"

Environment Variables:
Expand Down
14 changes: 0 additions & 14 deletions examples-copier/config.json

This file was deleted.

54 changes: 0 additions & 54 deletions examples-copier/configs/.env.example

This file was deleted.

97 changes: 0 additions & 97 deletions examples-copier/configs/.env.example.new

This file was deleted.

Loading