Synchronize files between repositories
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
lib
.gitignore
README.md
config.json.tpl
config1.png
config2.png
copycat-chart.png
copycat.png
copycat.svg
lint-staged.config.js
package.json
test-webhook-2.json
test-webhook.json

README.md

Copycat logo

Copycat

Copycat is a tool for synchronizing files between repositories.

It can:

  • create a web server,
  • listen to requests,
  • parse GitHub webhooks,
  • create pull requests to the target repository with the changes from the source repository

Copycat - how it works

Use cases

You can use Copycat to:

  • synchronize documentation between project repository and documentation repository
  • share code between multiple projects
  • connect a monorepo to a project's own repository

Getting Started

These instructions will get you Copycat up and running on your local machine

Prerequisites

To run Copycat, you will need node.js > 7.10.

Installation

Copy config.json.tpl as config.json and update config:

  • token – Github account's token you want to use for synchronization
  • userAgent – it will be used in requests to Github API
  • syncAccountName – the name of the account used for synchronization
  • syncFiles – an array of objects with the sync config

A sample config.json:

{
    "token": "xxx",
    "userAgent": "Copycat-Docs-Synchronizer",
    "syncAccountName": "livechat-docs-synchronizer",
    "pullRequestBranchPrefix": "update-libs-",
    "syncFiles": [
        {
            "from": {
                "owner": "livechat",
                "repo": "copycat",
                "path": "lib/"
            },
            "to": {
                "owner": "livechat",
                "repo": "copycat-lib-only",
                "path": "lib/"
            },
            "refsMap": {
                "labs": "labs",
                "master": "master"
            }
        }
    ]
}

Start

To start Copycat, run npm run start

Testing

To test Copycat, you'll need to expose your local server (created by Copycat with the npm run start command) to public and add a webhook to your GitHub repository.

Expose the server

To expose the local server, you can use ngrok. A detailed description is available in the Configuring Your Server section in the GitHub documentation.

./ngrok http 3081

Send webhook requests

Next, set up github to send webook requests to your local machine.

  1. Copy the address created by ngrok:

ngrok screenshot - exposed address

  1. Paste it to your GitHub webhook settings:

github screenshot - webhook setting

Deployment

The easiest way to deploy Copycat is to use a "node as a service" provider (AWS Elastic Beanstalk, Heroku or Zeit).

After the deployment, add a webhook to your GitHub repository

  1. Go to your repository’s Settings > Webhooks > Add webhook
  2. Paste there the URL of your deployed service, e.g. http://copycat.example.org/webhook/push

Changelog

[v0.0.2] - 22.11.2017

Fix destination directory

[v0.0.1] - 3.11.2017

First public Release

Authors

Konrad Kruk / LiveChat

Mateusz Burzyński / LiveChat

License

This project is licensed under the MIT License