Skip to content

Commit eb3f21a

Browse files
committed
docs: enhance README for copy-discussions.js with usage instructions and features
1 parent b3e800f commit eb3f21a

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

scripts/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,44 @@ Configuration values to change in the script:
3636

3737
Migrate work items from Azure DevOps to GitHub issues - this just links out to a [separate repo](https://github.com/joshjohanning/ado_workitems_to_github_issues)
3838

39+
## copy-discussions.js
40+
41+
Copy GitHub Discussions between repositories, including categories, labels, comments, and replies. This script can copy discussions across different GitHub instances and enterprises.
42+
43+
The script is expecting:
44+
45+
- environment variables `SOURCE_TOKEN` and `TARGET_TOKEN` with GitHub PATs that have `repo` and `read:discussion` scopes
46+
- dependencies installed via `npm i octokit`
47+
48+
Script usage:
49+
50+
```bash
51+
export SOURCE_TOKEN=ghp_abc
52+
export TARGET_TOKEN=ghp_xyz
53+
npm i octokit
54+
node ./copy-discussions.js source-org source-repo target-org target-repo
55+
```
56+
57+
Features:
58+
59+
- Automatically creates missing discussion categories in the target repository
60+
- Creates labels in the target repository if they don't exist
61+
- Copies all comments and threaded replies with proper attribution
62+
- Copies poll results as static snapshots (with table and optional Mermaid chart)
63+
- Handles rate limiting with exponential backoff
64+
- Provides colored console output for better visibility
65+
66+
Configuration:
67+
68+
- Set `INCLUDE_POLL_MERMAID_CHART = false` at the top of the script to disable Mermaid pie charts for polls
69+
70+
Notes:
71+
72+
- If a category doesn't exist in the target repository, discussions will be created in the "General" category
73+
- The script preserves discussion metadata by adding attribution text to the body and comments
74+
- Poll results are copied as static snapshots - voting is not available in copied discussions
75+
- Both source and target repositories must have GitHub Discussions enabled
76+
3977
## delete-branch-protection-rules.ps1
4078

4179
Delete branch protection rules programmatically based on a pattern.

0 commit comments

Comments
 (0)