docs/doc/source/developer_resources/mirror_repo.rst
Kristal Dale 40000df355 Add new page to Developer Resources section
Add a new page with instruction on how to mirror an OpenDev
repo to GitHub.

Patchset 5: Apply reST formatting and basic editorial for consistency.

Change-Id: Ib0d7784937da36557d4c365a758dde27534074e7
Signed-off-by: Kristal Dale <kristal.dale@intel.com>
2020-02-12 11:08:33 -08:00

3.6 KiB

Mirror OpenDev Repo to GitHub

This section describes the steps to create a Zuul job to sync an OpenDev repository to a GitHub repository.

Create Zuul job to sync OpenDev repository to GitHub

  1. Prepare GitHub repository.

    1. Create a new repository under github.com/starlingx. If possible, use the same repository name as original OpenDev repository.
    2. Grant 'write' permission to the starlingx-github user. Zuul will use the starlingx-github user to sync the repository.
  2. Generate an SSH key.

    Zuul is needed to generate an SSH key. Refer to the Zuul Quick-Start for Zuul installation instructions.

    From a server that has the Zuul tool installed, run the following command, where <repo> is the name of the repository. The SSH key is at the end of the output after <fieldname>: tag.

    zuul/tools/encrypt_secret.py --infile ./starlingx.github@gmail.com --strip --tenant \
    openstack https://zuul.opendev.org starlingx/<repo>
    
    writing RSA key
    Public key length: 4096 bits (512 bytes)
    Max plaintext length per chunk: 470 bytes
    Input plaintext length: 3246 bytes
    Number of chunks: 7
    
    - secret:
        name: <name>
        data:
          <fieldname>: <ssh_key>
  3. Add a new job to Zuul.

    Create a new job in .zuul.yaml in the root directory of the repository. The new job should look like the example below. Make sure to replace <repo> with the actual repository name. Replace <ssh_key> with the actual SSH key generated in the previous step.

    - job:
       name: stx-<repo>-upload-git-mirror
       parent: upload-git-mirror
       description: Mirrors opendev.org/starlingx/<repo> to github.com/starlingx/<repo>
       vars:
         git_mirror_repository: starlingx/<repo>
       secrets:
         - name: git_mirror_credentials
           secret: stx-<repo>-github-secret
           pass-to-parent: true
    
     - secret:
       name: stx-<repo>-github-secret
       data:
         user: git
         host: github.com
         # yamllint disable-line rule:line-length
         host_key: github.com ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAq2A7hRGmdnm9tUDbO9IDSwBK6TbQa+PXYPCPy6rbTrTtw7PHkccKrpp0yVhp5HdEIcKr6pLlVDBfOLX9QUsyCOV0wzfjIJNlGEYsdlLJizHhbn2mUjvSAHQqZETYP81eFzLQNnPHt4EVVUh7VfDESU84KezmD5QlWpXLmvU31/yMf+Se8xhHTvKSCZIFImWwoG6mbUoWf9nzpIoaSjB+weqqUUmpaaasXVal72J+UX2B+2RPW3RcT0eOzQgqlJL3RKrTJvdsjE3JEAvGq3lGHSZXy28G3skua2SmVi/w4yCE6gbODqnTWlg7+wC604ydGXA8VJiS5ap43JXiUFFAaQ==
         ssh_key: <ssh_key>
  4. Set the new job as a Zuul post job.

    Add the job (named stx-<repo>-upload-git-mirror) to the post job section of the .zuul.yaml file. If there isn't an existing post job, create a new post job section. The .zuul.yaml post job section should look like the example below. Make sure <repo> is replaced with the actual repository name.

    Example .zuul.yaml post job section:

    - project:
      post:
        jobs:
          stx-<repo>-upload-git-mirror

Example Zuul job

An example of adding a Zuul job to sync a repository from opendev.org/starlingx to github.com/starlingx can be found at:

https://opendev.org/starlingx/config/commit/5df1f3a89a6e1ef699fc6030a18902faf45daf88