This directory contains workflow configurations for automatically copying code examples to destination repositories. See Copy Files Automatically to Another Repo for the full documentation.
The copier app is owned by the Dev Docs team (source code)
To add a new workflow, create a new DOCSP Jira ticket with the component set to DevDocs.
- You merge a PR to
mainin this repository - Copier is notified of the merge via webhook
- Copier checks the filepaths from the PR. If any filepaths match a defined workflow:
- Files are copied to the one or more destination repositories
- The copier does nothing
You can optionally define how the copy is managed. Based on the workflow configuration:
- 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.
- 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.
workflows:
- name: "my-workflow"
destination:
repo: "mongodb/destination-repo"
branch: "main"
transformations:
- move:
from: "source/path"
to: "destination/path"Note: Patterns and paths are matched against the full repository path
Copy all files from one directory to another:
transformations:
- move:
from: "examples/go"
to: "code/go"Copy a specific file:
transformations:
- copy:
from: "README.md"
to: "docs/README.md"Use glob patterns for flexible matching:
transformations:
- glob:
pattern: "examples/**/*.go"
transform: "code/${relative_path}"Add custom PR titles and descriptions:
workflows:
- name: "my-workflow"
destination:
repo: "mongodb/destination-repo"
branch: "main"
transformations:
- move: { from: "src", to: "dest" }
commit_strategy:
type: "pull_request"
pr_title: "Update examples from ${source_repo}"
pr_body: |
Automated update from source repository.
Source PR: #${pr_number}
Commit: ${commit_sha}
auto_merge: falseUse these variables in PR titles, bodies, and commit messages:
${source_repo}- Source repository name${source_branch}- Source branch name${pr_number}- Source PR number${commit_sha}- Source commit SHA${file_count}- Number of files changed
Use these in path transformations:
${relative_path}- Path relative to the matched pattern${path}- Full source file path${filename}- Just the filename${dir}- Directory path${ext}- File extension
Prevent certain files from being copied:
workflows:
- name: "my-workflow"
destination:
repo: "mongodb/destination-repo"
branch: "main"
transformations:
- move: { from: "src", to: "dest" }
exclude:
- "**/.env"
- "**/node_modules/**"
- "**/*.test.js"# .copier/config.yaml
defaults:
commit_strategy:
type: "pull_request"
auto_merge: false
exclude:
- "**/.env"
- "**/node_modules/**"
workflows:
# Defaults apply unless overridden
- name: "go-examples"
destination:
repo: "mongodb/go-examples-repo"
branch: "main"
transformations:
- move:
from: "examples/go"
to: "code"
commit_strategy:
pr_title: "Update Go examples from ${source_repo}"
pr_body: |
Automated update of Go code examples.
**Source**: ${source_repo} (PR #${pr_number})
**Commit**: ${commit_sha}
**Files**: ${file_count} changed
deprecation_check:
enabled: true
file: "deprecated_examples.json"