One-click migration of GitHub repositories to CNB, with support for code and Release migration.
git push --mirrorBesides using in pipelines, you can also call this plugin directly via docker run:
docker run --rm \
-e TZ=Asia/Shanghai \
-e PLUGIN_CNB_TOKEN='cnb_xxxx' \
-e PLUGIN_GITHUB_REPO='owner/repo' \
-e PLUGIN_CNB_SLUG='your-cnb-org-slug' \
-e PLUGIN_GITHUB_TOKEN='ghp_xxxx' \
-e PLUGIN_CNB_REPO_NAME='your-cnb-repo-name' \
-e PLUGIN_MIGRATE_RELEASES='true' \
-e PLUGIN_VISIBILITY='private' \
docker.cnb.cool/dailybo/github2cnb:latest
Note:
cnb_tokenis required, needingrepo-contents:randrepo-code:rwpermissions. For public repositories,github_tokencan be omitted.
Use in .cnb.yml pipeline configuration:
main:
push:
- stages:
- name: migrate-to-cnb
image: docker.cnb.cool/your-org/github-to-cnb:latest
settings:
github_repo: owner/repo
cnb_slug: your-cnb-org-slug
# cnb_token: cnb_xxxx # Optional, required for cross-org operations
# github_token: ghp_xxxx # Optional, required for private repos
# cnb_repo_name: custom-name # Optional, defaults to GitHub repo name
# migrate_releases: true # Optional, defaults to true
# visibility: private # Optional, defaults to private
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
github_repo | string | Yes | - | GitHub repository address, format owner/repo |
cnb_slug | string | Yes | - | CNB organization slug |
cnb_token | string | Docker required | Pipeline auto-provided | CNB access token, required for cross-org operations |
github_token | string | Private repos required | - | GitHub Personal Access Token |
cnb_repo_name | string | No | GitHub repo name | CNB repository name |
migrate_releases | boolean | No | true | Whether to migrate Releases |
visibility | string | No | private | Repository visibility |
owner/repo format.Example:
settings:
github_repo: "octocat/hello-world"
Example:
settings:
cnb_slug: "my-org"
CNB_TOKENrepo-contents:r and repo-code:rw permissions. Auto-provided in pipelines; required for Docker direct usage; must be specified for cross-organization operations with a token that has target organization permissions.Example:
settings:
cnb_token: "cnb_xxxxxxxxxxxx"
Example:
settings:
github_token: "ghp_xxxxxxxxxxxx"
Example:
settings:
cnb_repo_name: "my-custom-repo"
Example:
settings:
migrate_releases: false
private or public. Only takes effect when creating a new repository; existing repositories will not be modified.Example:
settings:
visibility: "public"
After migration, the following pipeline variables are output:
##[set-output github2cnb-repo-url=https://cnb.cool/my-org/my-repo]
##[set-output github2cnb-repo-slug=my-org/my-repo]
Can be referenced in subsequent steps via @{github2cnb-repo-url} and @{github2cnb-repo-slug}.
main:
push:
- stages:
- name: migrate-to-cnb
image: docker.cnb.cool/your-org/github-to-cnb:latest
settings:
github_repo: octocat/hello-world
cnb_slug: my-org
migrate_releases: true
visibility: public
exports:
github2cnb-repo-url: GITHUB2CNB_REPO_URL
github2cnb-repo-slug: GITHUB2CNB_REPO_SLUG
- name: echo result
script:
- echo "GITHUB2CNB_REPO_URL $GITHUB2CNB_REPO_URL"
- echo "GITHUB2CNB_REPO_SLUG $GITHUB2CNB_REPO_SLUG"
git clone --bare + git push --mirrorOn API errors or missing parameters, the plugin will exit with a non-zero status code, causing the pipeline to fail.
MIT License