Skip to content

Commit 40ff772

Browse files
authored
Merge branch 'main' into development
2 parents 2491f22 + 8de232d commit 40ff772

6 files changed

Lines changed: 344 additions & 368 deletions

File tree

.copier/README.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# Code Copier Workflows
2+
3+
This directory contains workflow configurations for automatically copying code examples to destination repositories.
4+
5+
The copier app is owned by the Dev Docs team.
6+
7+
## Adding a New Workflow
8+
9+
To add a new workflow, create a new DOCSP Jira ticket with the component set to `DevDocs`.
10+
11+
## How It Works
12+
13+
1. **You merge a PR** to ``main`` in this repository
14+
2. **Copier is notified** of the merge via webhook
15+
3. **Copier checks the filepaths** from the PR. If any filepaths match a defined workflow:
16+
- **Files are copied** to the one or more destination repositories
17+
- The copier does nothing
18+
19+
You can optionally define *how* the copy is managed. Based on the workflow configuration:
20+
- The copier creates a PR in the destination repository (**default**). You can set your own process for handling that PR, which may involve manual testing or review.
21+
- The copier commits directly to the destination repository **without a PR**. You may prefer this option if you want a fully automated workflow with no review at the destination repo.
22+
23+
Source Code: [Code Example Tooling Repository](https://github.com/mongodb/code-example-tooling)
24+
25+
## Basic Workflow Structure
26+
27+
```yaml
28+
workflows:
29+
- name: "my-workflow"
30+
destination:
31+
repo: "mongodb/destination-repo"
32+
branch: "main"
33+
transformations:
34+
- move:
35+
from: "source/path"
36+
to: "destination/path"
37+
```
38+
39+
Note: Patterns and paths are matched against the full repository path
40+
41+
## Common Transformation Types
42+
43+
### Move Directory
44+
45+
Copy all files from one directory to another:
46+
47+
```yaml
48+
transformations:
49+
- move:
50+
from: "examples/go"
51+
to: "code/go"
52+
```
53+
54+
### Copy Single File
55+
56+
Copy a specific file:
57+
58+
```yaml
59+
transformations:
60+
- copy:
61+
from: "README.md"
62+
to: "docs/README.md"
63+
```
64+
65+
### Match with Wildcards
66+
67+
Use glob patterns for flexible matching:
68+
69+
```yaml
70+
transformations:
71+
- glob:
72+
pattern: "examples/**/*.go"
73+
transform: "code/${relative_path}"
74+
```
75+
76+
## Customizing PR Details
77+
78+
Add custom PR titles and descriptions:
79+
80+
```yaml
81+
workflows:
82+
- name: "my-workflow"
83+
destination:
84+
repo: "mongodb/destination-repo"
85+
branch: "main"
86+
transformations:
87+
- move: { from: "src", to: "dest" }
88+
commit_strategy:
89+
type: "pull_request"
90+
pr_title: "Update examples from ${source_repo}"
91+
pr_body: |
92+
Automated update from source repository.
93+
94+
Source PR: #${pr_number}
95+
Commit: ${commit_sha}
96+
auto_merge: false
97+
```
98+
99+
## Available Variables
100+
101+
Use these variables in PR titles, bodies, and commit messages:
102+
103+
- `${source_repo}` - Source repository name
104+
- `${source_branch}` - Source branch name
105+
- `${pr_number}` - Source PR number
106+
- `${commit_sha}` - Source commit SHA
107+
- `${file_count}` - Number of files changed
108+
109+
Use these in path transformations:
110+
111+
- `${relative_path}` - Path relative to the matched pattern
112+
- `${path}` - Full source file path
113+
- `${filename}` - Just the filename
114+
- `${dir}` - Directory path
115+
- `${ext}` - File extension
116+
117+
## Excluding Files
118+
119+
Prevent certain files from being copied:
120+
121+
```yaml
122+
workflows:
123+
- name: "my-workflow"
124+
destination:
125+
repo: "mongodb/destination-repo"
126+
branch: "main"
127+
transformations:
128+
- move: { from: "src", to: "dest" }
129+
exclude:
130+
- "**/.env"
131+
- "**/node_modules/**"
132+
- "**/*.test.js"
133+
```
134+
135+
## Example: Complete Workflow
136+
137+
```yaml
138+
# .copier/config.yaml
139+
140+
defaults:
141+
commit_strategy:
142+
type: "pull_request"
143+
auto_merge: false
144+
exclude:
145+
- "**/.env"
146+
- "**/node_modules/**"
147+
148+
workflows:
149+
# Defaults apply unless overridden
150+
- name: "go-examples"
151+
destination:
152+
repo: "mongodb/go-examples-repo"
153+
branch: "main"
154+
transformations:
155+
- move:
156+
from: "examples/go"
157+
to: "code"
158+
commit_strategy:
159+
pr_title: "Update Go examples from ${source_repo}"
160+
pr_body: |
161+
Automated update of Go code examples.
162+
163+
**Source**: ${source_repo} (PR #${pr_number})
164+
**Commit**: ${commit_sha}
165+
**Files**: ${file_count} changed
166+
deprecation_check:
167+
enabled: true
168+
file: "deprecated_examples.json"
169+
```

.copier/config.yaml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Docs Copier Workflow Configuration
2+
# Referenced from main config file in https://github.com/mongodb/code-example-tooling/blob/main/.copier/workflows/main.yaml
3+
4+
# ============================================================================
5+
# LOCAL DEFAULTS
6+
# ============================================================================
7+
# These defaults apply to all workflows in this file
8+
# They override main config defaults but can be overridden by individual workflows
9+
10+
11+
defaults:
12+
commit_strategy:
13+
type: "pull_request"
14+
auto_merge: false
15+
use_pr_template: true
16+
commit_message: "Automated update from ${source_repo} PR #${pr_number} (${file_count} files)"
17+
deprecation_check:
18+
enabled: true
19+
file: "deprecated_examples.json"
20+
exclude:
21+
- "**/.env"
22+
- "**/node_modules/**"
23+
- "**/.DS_Store"
24+
- "\\.gitignore$"
25+
- "README.md$"
26+
27+
# ============================================================================
28+
# WORKFLOW CONFIGURATION
29+
# ============================================================================
30+
# To add a workflow, create a DOCSP Jira ticket with the component set to `DevDocs`.
31+
# See also [README.md](https://github.com/mongodb/docs-sample-apps/blob/main/.copier/README.md)
32+
33+
workflows:
34+
35+
# --------------------------------------------------------------------------
36+
# MFlix Java Application
37+
# --------------------------------------------------------------------------
38+
- name: "mflix-java"
39+
destination:
40+
repo: "mongodb/sample-app-java-mflix"
41+
branch: "main"
42+
transformations:
43+
- move: { from: "mflix/client", to: "client" }
44+
- move: { from: "mflix/server/java-spring", to: "server" }
45+
- copy: { from: "mflix/README-JAVA-SPRING.md", to: "README.md" }
46+
- copy: { from: "mflix/.gitignore-java", to: ".gitignore" }
47+
commit_strategy:
48+
pr_title: "Update MFlix application from docs-sample-apps"
49+
pr_body: |
50+
Automated update of MFlix Java application
51+
52+
**Source:** ${source_repo} (${source_branch})
53+
**PR:** #${pr_number} | **Commit:** ${commit_sha}
54+
**Changes:** ${file_count} files
55+
exclude:
56+
- "mflix/client/**/.gitignore"
57+
- "mflix/server/java-spring/**/.gitignore"
58+
59+
60+
# --------------------------------------------------------------------------
61+
# MFlix Node.js Application
62+
# --------------------------------------------------------------------------
63+
- name: "mflix-nodejs"
64+
destination:
65+
repo: "mongodb/sample-app-nodejs-mflix"
66+
branch: "main"
67+
transformations:
68+
- move: { from: "mflix/client", to: "client" }
69+
- move: { from: "mflix/server/js-express", to: "server" }
70+
- copy: { from: "mflix/README-JAVASCRIPT-EXPRESS.md", to: "README.md" }
71+
- copy: { from: "mflix/.gitignore-js", to: ".gitignore" }
72+
commit_strategy:
73+
pr_title: "Update MFlix application from docs-sample-apps"
74+
pr_body: |
75+
Automated update of MFlix Node.js application
76+
77+
**Source:** ${source_repo} (${source_branch})
78+
**PR:** #${pr_number} | **Commit:** ${commit_sha}
79+
**Changes:** ${file_count} files
80+
exclude:
81+
- "mflix/client/**/.gitignore"
82+
- "mflix/server/js-express/**/.gitignore"
83+
84+
85+
# --------------------------------------------------------------------------
86+
# MFlix Python Application
87+
# --------------------------------------------------------------------------
88+
- name: "mflix-python"
89+
destination:
90+
repo: "mongodb/sample-app-python-mflix"
91+
branch: "main"
92+
transformations:
93+
- move: { from: "mflix/client", to: "client" }
94+
- move: { from: "mflix/server/python-fastapi", to: "server" }
95+
- copy: { from: "mflix/README-PYTHON-FASTAPI.md", to: "README.md" }
96+
- copy: { from: "mflix/.gitignore-python", to: ".gitignore" }
97+
commit_strategy:
98+
pr_title: "Update MFlix application from docs-sample-apps"
99+
pr_body: |
100+
Automated update of MFlix Python application
101+
102+
**Source:** ${source_repo} (${source_branch})
103+
**PR:** #${pr_number} | **Commit:** ${commit_sha}
104+
**Changes:** ${file_count} files
105+
exclude:
106+
- "mflix/client/**/.gitignore"
107+
- "mflix/server/python-fastapi/**/.gitignore"

.github/CODEOWNERS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@mongodb/devdocs

0 commit comments

Comments
 (0)