Skip to content

Commit bc25daa

Browse files
authored
Merge pull request #83 from cbullinger/quick-fix
Fast follows for copier app enhancements
2 parents 8bbb258 + 65f27e2 commit bc25daa

30 files changed

+2359
-670
lines changed

examples-copier/.gitignore

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Binaries
2+
examples-copier
3+
*.exe
4+
*.exe~
5+
*.dll
6+
*.so
7+
*.dylib
8+
9+
# Test binary, built with `go test -c`
10+
*.test
11+
12+
# Output of the go coverage tool
13+
*.out
14+
15+
# Dependency directories
16+
vendor/
17+
18+
# Go workspace file
19+
go.work
20+
21+
# Environment files with secrets
22+
env.yaml
23+
.env
24+
.env.local
25+
.env.production
26+
.env.*.local
27+
28+
# Private keys
29+
*.pem
30+
*.key
31+
32+
# IDE files
33+
.idea/
34+
.vscode/
35+
*.swp
36+
*.swo
37+
*~
38+
39+
# OS files
40+
.DS_Store
41+
Thumbs.db
42+
43+
# Logs
44+
*.log
45+
46+
# Temporary files
47+
tmp/
48+
temp/
49+
50+
env.yaml

examples-copier/Makefile

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,16 @@ test-webhook:
6060
# Test with example payload
6161
test-webhook-example: test-webhook
6262
@echo "Testing with example payload..."
63-
@./test-webhook -payload test-payloads/example-pr-merged.json
63+
@if [ -z "$$WEBHOOK_SECRET" ]; then \
64+
echo "Fetching webhook secret from Secret Manager..."; \
65+
export WEBHOOK_SECRET=$$(gcloud secrets versions access latest --secret=webhook-secret 2>/dev/null); \
66+
fi; \
67+
if [ -n "$$WEBHOOK_SECRET" ]; then \
68+
./test-webhook -payload test-payloads/example-pr-merged.json -secret "$$WEBHOOK_SECRET"; \
69+
else \
70+
echo "Warning: WEBHOOK_SECRET not set, sending without signature"; \
71+
./test-webhook -payload test-payloads/example-pr-merged.json; \
72+
fi
6473

6574
# Test with real PR (requires PR, OWNER, REPO variables)
6675
test-webhook-pr: test-webhook
@@ -69,7 +78,16 @@ test-webhook-pr: test-webhook
6978
echo "Usage: make test-webhook-pr PR=123 OWNER=myorg REPO=myrepo"; \
7079
exit 1; \
7180
fi
72-
@./test-webhook -pr $(PR) -owner $(OWNER) -repo $(REPO)
81+
@if [ -z "$$WEBHOOK_SECRET" ]; then \
82+
echo "Fetching webhook secret from Secret Manager..."; \
83+
export WEBHOOK_SECRET=$$(gcloud secrets versions access latest --secret=webhook-secret 2>/dev/null); \
84+
fi; \
85+
if [ -n "$$WEBHOOK_SECRET" ]; then \
86+
./test-webhook -pr $(PR) -owner $(OWNER) -repo $(REPO) -secret "$$WEBHOOK_SECRET"; \
87+
else \
88+
echo "Warning: WEBHOOK_SECRET not set, sending without signature"; \
89+
./test-webhook -pr $(PR) -owner $(OWNER) -repo $(REPO); \
90+
fi
7391

7492
# Test with real PR using helper script
7593
test-pr:

examples-copier/QUICK-REFERENCE.md

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,29 @@ curl http://localhost:8080/health
382382
curl http://localhost:8080/metrics | jq
383383
```
384384

385+
## Deployment
386+
387+
### Google Cloud Quick Commands
388+
389+
```bash
390+
# Deploy (env.yaml is included via 'includes' directive in app.yaml)
391+
gcloud app deploy app.yaml
392+
393+
# View logs
394+
gcloud app logs tail -s default
395+
396+
# Check health
397+
curl https://github-copy-code-examples.appspot.com/health
398+
399+
# List secrets
400+
gcloud secrets list
401+
402+
# Grant access
403+
./grant-secret-access.sh
404+
```
405+
406+
407+
385408
## File Locations
386409

387410
```
@@ -390,7 +413,9 @@ examples-copier/
390413
├── MIGRATION-GUIDE.md # Migration from legacy
391414
├── QUICK-REFERENCE.md # This file
392415
├── REFACTORING-SUMMARY.md # Feature details
393-
├── DEPLOYMENT-GUIDE.md # Deployment instructions
416+
├── docs/
417+
│ ├── DEPLOYMENT.md # Deployment guide
418+
│ └── DEPLOYMENT-CHECKLIST.md # Deployment checklist
394419
├── TESTING-SUMMARY.md # Test documentation
395420
├── configs/
396421
│ ├── .env # Environment config

examples-copier/README.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ GITHUB_INSTALLATION_ID=789012
6666

6767
# Google Cloud
6868
GCP_PROJECT_ID=your-project
69-
PEM_KEY_NAME=projects/123/secrets/CODE_COPIER_PEM/versions/latest
69+
PEM_KEY_NAME=projects/123/secrets/<name>/versions/latest
70+
WEBHOOK_SECRET_NAME=projects/123/secrets/webhook-secret
7071

7172
# Application Settings
7273
PORT=8080
@@ -415,7 +416,7 @@ container := NewServiceContainer(config)
415416

416417
## Deployment
417418

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

420421
### Google Cloud App Engine
421422

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

449451
### Reference
450452

examples-copier/app.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,17 @@ func main() {
3939
os.Exit(1)
4040
}
4141

42+
// Load secrets from Secret Manager if not directly provided
43+
if err := services.LoadWebhookSecret(config); err != nil {
44+
fmt.Printf("❌ Error loading webhook secret: %v\n", err)
45+
os.Exit(1)
46+
}
47+
48+
if err := services.LoadMongoURI(config); err != nil {
49+
fmt.Printf("❌ Error loading MongoDB URI: %v\n", err)
50+
os.Exit(1)
51+
}
52+
4253
// Override dry-run from command line
4354
if dryRun {
4455
config.DryRun = true

examples-copier/app.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@ runtime_config:
33
operating_system: "ubuntu22"
44
runtime_version: "1.23"
55
env: flex
6+
7+
includes:
8+
- env.yaml

examples-copier/cmd/test-webhook/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func main() {
2020
prNumber := flag.Int("pr", 0, "PR number to fetch from GitHub")
2121
owner := flag.String("owner", "", "Repository owner")
2222
repo := flag.String("repo", "", "Repository name")
23-
webhookURL := flag.String("url", "http://localhost:8080/webhook", "Webhook URL")
23+
webhookURL := flag.String("url", "http://localhost:8080/events", "Webhook URL")
2424
secret := flag.String("secret", "", "Webhook secret for signature")
2525
payloadFile := flag.String("payload", "", "Path to custom payload JSON file")
2626
dryRun := flag.Bool("dry-run", false, "Print payload without sending")
@@ -95,7 +95,7 @@ Options:
9595
-pr int PR number to fetch from GitHub
9696
-owner string Repository owner (required with -pr)
9797
-repo string Repository name (required with -pr)
98-
-url string Webhook URL (default: http://localhost:8080/webhook)
98+
-url string Webhook URL (default: http://localhost:8080/events)
9999
-secret string Webhook secret for HMAC signature
100100
-payload string Path to custom payload JSON file
101101
-dry-run Print payload without sending
@@ -117,7 +117,7 @@ Examples:
117117
118118
# Send to production with secret
119119
test-webhook -pr 123 -owner myorg -repo myrepo \
120-
-url https://myapp.appspot.com/webhook \
120+
-url https://myapp.appspot.com/events \
121121
-secret "my-webhook-secret"
122122
123123
Environment Variables:

examples-copier/config.json

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

examples-copier/configs/.env.example

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

examples-copier/configs/.env.example.new

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

0 commit comments

Comments
 (0)