Skip to content

Commit 5c1aa71

Browse files
authored
Merge pull request #94 from mongodb/copier-workflow-enh
Copier Enhancement: Multi-Org Support and Workflow-Based Configs
2 parents dae638a + d5af4a0 commit 5c1aa71

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+5545
-7333
lines changed

.copier/workflows/main.yaml renamed to .copier/main.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ workflow_configs:
2929
- source: "repo"
3030
repo: "mongodb/docs-sample-apps"
3131
branch: "main" # optional, defaults to main
32-
path: ".copier/workflows.yaml"
32+
path: ".copier/config.yaml"
3333
enabled: true
3434

3535
# --------------------------------------------------------------------------
@@ -38,7 +38,7 @@ workflow_configs:
3838
- source: "repo"
3939
repo: "10gen/docs-mongodb-internal"
4040
branch: "main"
41-
path: ".copier/workflows.yaml"
41+
path: ".copier/config.yaml"
4242
enabled: true
4343

4444
# --------------------------------------------------------------------------
@@ -47,7 +47,7 @@ workflow_configs:
4747
- source: "repo"
4848
repo: "mongodb/docs-code-examples"
4949
branch: "main"
50-
path: ".copier/workflows.yaml"
50+
path: ".copier/config.yaml"
5151
enabled: false
5252

5353
# --------------------------------------------------------------------------

examples-copier/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Build stage
2-
FROM golang:1.23.4-alpine AS builder
2+
FROM golang:1.24.0-alpine AS builder
33

44
# Install build dependencies
55
RUN apk add --no-cache git ca-certificates

examples-copier/QUICK-REFERENCE.md

Lines changed: 81 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -42,37 +42,43 @@
4242

4343
## Configuration Patterns
4444

45-
### Prefix Pattern
45+
### Move Transformation
4646
```yaml
47-
source_pattern:
48-
type: "prefix"
49-
pattern: "examples/go/"
47+
transformations:
48+
- move:
49+
from: "examples/go"
50+
to: "code/go"
5051
```
5152
52-
### Glob Pattern
53+
### Glob Transformation
5354
```yaml
54-
source_pattern:
55-
type: "glob"
56-
pattern: "examples/*/main.go"
55+
transformations:
56+
- glob:
57+
pattern: "examples/*/main.go"
58+
transform: "code/${relative_path}"
5759
```
5860
59-
### Regex Pattern
61+
### Regex Transformation
6062
```yaml
61-
source_pattern:
62-
type: "regex"
63-
pattern: "^examples/(?P<lang>[^/]+)/(?P<file>.+)$"
63+
transformations:
64+
- regex:
65+
pattern: "^examples/(?P<lang>[^/]+)/(?P<file>.+)$"
66+
transform: "code/${lang}/${file}"
6467
```
6568
66-
### Pattern with Exclusions
69+
### Workflow with Exclusions
6770
```yaml
68-
source_pattern:
69-
type: "prefix"
70-
pattern: "examples/"
71-
exclude_patterns:
72-
- "\.gitignore$"
73-
- "node_modules/"
74-
- "\.env$"
75-
- "/dist/"
71+
workflows:
72+
- name: "Copy examples"
73+
transformations:
74+
- move:
75+
from: "examples"
76+
to: "code"
77+
exclude:
78+
- "**/.gitignore"
79+
- "**/node_modules/**"
80+
- "**/.env"
81+
- "**/dist/**"
7682
```
7783
7884
## Path Transformations
@@ -118,36 +124,22 @@ commit_strategy:
118124
auto_merge: true
119125
```
120126

121-
### Batch PRs by Repository
122-
```yaml
123-
batch_by_repo: true
124-
125-
batch_pr_config:
126-
pr_title: "Update from ${source_repo}"
127-
pr_body: |
128-
🤖 Automated update
129-
Files: ${file_count}
130-
use_pr_template: true
131-
commit_message: "Update from ${source_repo} PR #${pr_number}"
132-
```
133-
134127
## Advanced Features
135128

136129
### Exclude Patterns
137-
Exclude unwanted files from being copied:
130+
Exclude unwanted files from being copied at the workflow level:
138131

139132
```yaml
140-
source_pattern:
141-
type: "prefix"
142-
pattern: "examples/"
143-
exclude_patterns:
144-
- "\.gitignore$" # Exclude .gitignore
145-
- "node_modules/" # Exclude dependencies
146-
- "\.env$" # Exclude .env files
147-
- "\.env\\..*$" # Exclude .env.local, .env.production, etc.
148-
- "/dist/" # Exclude build output
149-
- "/build/" # Exclude build artifacts
150-
- "\.test\.(js|ts)$" # Exclude test files
133+
workflows:
134+
- name: "Copy examples"
135+
exclude:
136+
- "**/.gitignore" # Exclude .gitignore
137+
- "**/node_modules/**" # Exclude dependencies
138+
- "**/.env" # Exclude .env files
139+
- "**/.env.*" # Exclude .env.local, .env.production, etc.
140+
- "**/dist/**" # Exclude build output
141+
- "**/build/**" # Exclude build artifacts
142+
- "**/*.test.js" # Exclude test files
151143
```
152144

153145
### PR Template Integration
@@ -167,20 +159,6 @@ commit_strategy:
167159
2. Separator (`---`)
168160
3. Your configured content (automation info)
169161

170-
### Batch Configuration
171-
When `batch_by_repo: true`, use `batch_pr_config` for accurate file counts:
172-
173-
```yaml
174-
batch_by_repo: true
175-
176-
batch_pr_config:
177-
pr_title: "Update from ${source_repo}"
178-
pr_body: |
179-
Files: ${file_count} # Accurate count across all rules
180-
Source: ${source_repo} PR #${pr_number}
181-
use_pr_template: true
182-
```
183-
184162
## Message Templates
185163

186164
### Available Variables
@@ -385,44 +363,60 @@ go build -o test-webhook ./cmd/test-webhook
385363

386364
### Copy All Go Files
387365
```yaml
388-
source_pattern:
389-
type: "regex"
390-
pattern: "^examples/.*\\.go$"
391-
targets:
392-
- repo: "org/docs"
393-
path_transform: "code/${path}"
366+
workflows:
367+
- name: "Copy Go files"
368+
source:
369+
repo: "org/source"
370+
branch: "main"
371+
destination:
372+
repo: "org/docs"
373+
branch: "main"
374+
transformations:
375+
- regex:
376+
pattern: "^examples/.*\\.go$"
377+
transform: "code/${path}"
394378
```
395379

396380
### Organize by Language
397381
```yaml
398-
source_pattern:
399-
type: "regex"
400-
pattern: "^examples/(?P<lang>[^/]+)/(?P<rest>.+)$"
401-
targets:
402-
- repo: "org/docs"
403-
path_transform: "languages/${lang}/${rest}"
382+
workflows:
383+
- name: "Organize by language"
384+
transformations:
385+
- regex:
386+
pattern: "^examples/(?P<lang>[^/]+)/(?P<rest>.+)$"
387+
transform: "languages/${lang}/${rest}"
404388
```
405389

406-
### Multiple Targets with Different Transforms
390+
### Multiple Workflows for Different Destinations
407391
```yaml
408-
source_pattern:
409-
type: "prefix"
410-
pattern: "examples/"
411-
targets:
412-
- repo: "org/docs-v1"
413-
path_transform: "examples/${path}"
414-
- repo: "org/docs-v2"
415-
path_transform: "code-samples/${path}"
392+
workflows:
393+
- name: "Copy to docs-v1"
394+
destination:
395+
repo: "org/docs-v1"
396+
branch: "main"
397+
transformations:
398+
- move:
399+
from: "examples"
400+
to: "examples"
401+
402+
- name: "Copy to docs-v2"
403+
destination:
404+
repo: "org/docs-v2"
405+
branch: "main"
406+
transformations:
407+
- move:
408+
from: "examples"
409+
to: "code-samples"
416410
```
417411

418412
### Conditional Copying (by file type)
419413
```yaml
420-
source_pattern:
421-
type: "regex"
422-
pattern: "^examples/.*\\.(?P<ext>go|py|js)$"
423-
targets:
424-
- repo: "org/docs"
425-
path_transform: "code/${ext}/${filename}"
414+
workflows:
415+
- name: "Copy by file type"
416+
transformations:
417+
- regex:
418+
pattern: "^examples/.*\\.(?P<ext>go|py|js)$"
419+
transform: "code/${ext}/${filename}"
426420
```
427421

428422
## Troubleshooting

0 commit comments

Comments
 (0)