|
1 | | -# gh-extension-template |
| 1 | +# GitHub Migration Validator |
2 | 2 |
|
3 | | -`gh-extension-template` is a template for creating GitHub CLI extensions. It provides a basic structure and some common features to help you get started quickly. |
| 3 | +A GitHub CLI extension for validating GitHub organization and repository migrations by comparing key metrics between source and target repositories. |
| 4 | + |
| 5 | +## Overview |
| 6 | + |
| 7 | +The GitHub Migration Validator helps ensure that your migration from one GitHub organization/repository to another has been completed successfully. It compares various repository metrics (issues, pull requests, tags, releases, commits) between source and target repositories and provides a detailed validation report. |
4 | 8 |
|
5 | 9 | ## Install |
6 | 10 |
|
7 | 11 | ```bash |
8 | | -gh extension install mona-actions/<repo-name> |
| 12 | +gh extension install mona-actions/gh-migration-validator |
9 | 13 | ``` |
10 | 14 |
|
11 | | -## Dependencies |
| 15 | +## Usage |
12 | 16 |
|
13 | | -- [Go](https://golang.org/doc/install) 1.20 or higher |
14 | | -- Key dependencies: |
15 | | - - [Cobra](https://github.com/spf13/cobra) - CLI framework for command line applications |
16 | | - - [Viper](https://github.com/spf13/viper) - Configuration management with environment variable support |
17 | | - - [go-github](https://github.com/google/go-github) - GitHub REST API v3 client |
18 | | - - [githubv4](https://github.com/shurcooL/githubv4) - GitHub GraphQL API v4 client |
19 | | - - [go-githubauth](https://github.com/jferrl/go-githubauth) - GitHub App authentication |
20 | | - - [go-github-ratelimit](https://github.com/gofri/go-github-ratelimit) - Rate limit handling |
| 17 | +### Basic Usage |
| 18 | + |
| 19 | +```bash |
| 20 | +gh migration-validator \ |
| 21 | + --source-organization "source-org" \ |
| 22 | + --target-organization "target-org" \ |
| 23 | + --source-repo "my-repo" \ |
| 24 | + --target-repo "my-repo" \ |
| 25 | + --source-token "ghp_xxx" \ |
| 26 | + --target-token "ghp_yyy" |
| 27 | +``` |
21 | 28 |
|
22 | | -## Features |
| 29 | +### With Markdown Output |
23 | 30 |
|
24 | | -- Pre-configured GitHub API clients: |
25 | | - - REST API client using [`go-github`](https://github.com/google/go-github) |
26 | | - - GraphQL API client with rate limit handling |
27 | | - - Support for both Personal Access Token and GitHub App authentication |
28 | | - - Enterprise Server support via hostname configuration |
| 31 | +```bash |
| 32 | +gh migration-validator \ |
| 33 | + --source-organization "source-org" \ |
| 34 | + --target-organization "target-org" \ |
| 35 | + --source-repo "my-repo" \ |
| 36 | + --target-repo "my-repo" \ |
| 37 | + --source-token "ghp_xxx" \ |
| 38 | + --target-token "ghp_yyy" \ |
| 39 | + --markdown-table |
| 40 | +``` |
29 | 41 |
|
30 | | -- Common CLI flags: |
31 | | - - Source/target organization flags |
32 | | - - Token authentication flags |
33 | | - - Enterprise hostname support |
34 | | - - All flags support environment variable configuration |
| 42 | +### Environment Variables |
35 | 43 |
|
36 | | -- Built-in release management: |
37 | | - - Automated versioning using Release Drafter |
38 | | - - Version bumping based on PR labels |
39 | | - - Automated changelog generation |
40 | | - - Pre-compiled extension binaries |
| 44 | +You can use environment variables instead of flags: |
41 | 45 |
|
42 | | -### Environment variables |
| 46 | +```bash |
| 47 | +export GHMV_SOURCE_ORGANIZATION="source-org" |
| 48 | +export GHMV_TARGET_ORGANIZATION="target-org" |
| 49 | +export GHMV_SOURCE_TOKEN="ghp_xxx" |
| 50 | +export GHMV_TARGET_TOKEN="ghp_yyy" |
| 51 | +export GHMV_SOURCE_REPO="my-repo" |
| 52 | +export GHMV_TARGET_REPO="my-repo" |
| 53 | +export GHMV_MARKDOWN_TABLE="true" |
| 54 | + |
| 55 | +gh migration-validator |
| 56 | +``` |
43 | 57 |
|
44 | | -GitHub App authentication in this template is not handled by flags, but by environment variables. You can set them in your shell or in a `.env` file. |
45 | | -This can be quickly changed to add flags for the app ID, private key, and installation ID. |
| 58 | +### GitHub App Authentication |
| 59 | + |
| 60 | +For GitHub App authentication, use environment variables: |
| 61 | + |
| 62 | +```bash |
| 63 | +# Source GitHub App |
| 64 | +export GHMV_SOURCE_APP_ID="123456" |
| 65 | +export GHMV_SOURCE_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n..." |
| 66 | +export GHMV_SOURCE_INSTALLATION_ID="987654" |
| 67 | + |
| 68 | +# Target GitHub App |
| 69 | +export GHMV_TARGET_APP_ID="123457" |
| 70 | +export GHMV_TARGET_PRIVATE_KEY="-----BEGIN RSA PRIVATE KEY-----\n..." |
| 71 | +export GHMV_TARGET_INSTALLATION_ID="987655" |
| 72 | +``` |
46 | 73 |
|
47 | | -It's recommended to use the prefix set in the `viper` configuration, which is `GHET_` in this case, to avoid conflicts with other environment variables. |
| 74 | +### Enterprise Server Support |
48 | 75 |
|
49 | | -```sh |
50 | | -# Required for GitHub App auth |
51 | | -export GHET_SOURCE_APP_ID="123456" |
52 | | -export GHET_SOURCE_PRIVATE_KEY="-----BEGIN RSA -----\n..." |
53 | | -export GHET_SOURCE_INSTALLATION_ID="987654" |
| 76 | +For GitHub Enterprise Server: |
54 | 77 |
|
55 | | -# Optional Enterprise Server URL |
56 | | -export GHET_SOURCE_HOSTNAME="https://github.example.com" |
| 78 | +```bash |
| 79 | +export GHMV_SOURCE_HOSTNAME="https://github.example.com" |
57 | 80 | ``` |
58 | 81 |
|
| 82 | +## What Gets Validated |
| 83 | + |
| 84 | +The tool compares the following metrics between source and target repositories: |
| 85 | + |
| 86 | +- **Issues**: Total count (expects +1 in target for migration log issue) |
| 87 | +- **Pull Requests**: Total, Open, Merged, and Closed counts |
| 88 | +- **Tags**: Total count of Git tags |
| 89 | +- **Releases**: Total count of GitHub releases |
| 90 | +- **Commits**: Total commit count on default branch |
| 91 | +- **Latest Commit SHA**: Ensures both repositories have the same latest commit in default branch |
| 92 | + |
| 93 | +## Validation Results |
| 94 | + |
| 95 | +- ✅ **PASS**: Metrics match expected values |
| 96 | +- ❌ **FAIL**: Target is missing data from source |
| 97 | +- ⚠️ **WARN**: Target has more data than source (usually acceptable) |
| 98 | + |
| 99 | +## Output Formats |
| 100 | + |
| 101 | +### Console Output |
| 102 | +The tool provides a formatted table with colored status indicators and a summary. |
| 103 | + |
| 104 | +### Markdown Output |
| 105 | +Use the `--markdown-table` flag to generate copy-paste ready markdown for documentation. |
| 106 | + |
| 107 | +## Dependencies |
| 108 | + |
| 109 | +- [Go](https://golang.org/doc/install) 1.20 or higher |
| 110 | +- Key dependencies: |
| 111 | + - [Cobra](https://github.com/spf13/cobra) - CLI framework |
| 112 | + - [Viper](https://github.com/spf13/viper) - Configuration management |
| 113 | + - [go-github](https://github.com/google/go-github) - GitHub REST API client |
| 114 | + - [githubv4](https://github.com/shurcooL/githubv4) - GitHub GraphQL API client |
| 115 | + - [go-githubauth](https://github.com/jferrl/go-githubauth) - GitHub App authentication |
| 116 | + - [go-github-ratelimit](https://github.com/gofri/go-github-ratelimit) - Rate limit handling |
| 117 | + - [pterm](https://github.com/pterm/pterm) - Terminal styling and formatting |
| 118 | + |
| 119 | +## Contributing |
| 120 | + |
| 121 | +Contributions are welcome! Please see [CONTRIBUTING.md](.github/contributing.md) for guidelines. |
| 122 | + |
59 | 123 | ## License |
60 | 124 |
|
61 | | -- [MIT](./license) (c) [Mona-Actions](https://github.com/mona-actions) |
62 | | -- [Contributing](./contributing.md) |
| 125 | +[MIT](./LICENSE) © [Mona-Actions](https://github.com/mona-actions) |
0 commit comments