Giter Site home page Giter Site logo

docker-gitsplit's Introduction

A Docker image with git and splitsh-lite

See the official site for more information about splitsh.

Usage

Include a .gitsplit.yml file in the root of your repository. This section provides a brief overview of the configuration file and split process.

Use env variable to inject your credential and manage authentication.

Example .gitsplit.yml configuration:

# Used to speed up the split over time by reusing git's objects
cache_dir: "/cache/gitsplit"

# Path to the repository to split (default = current path)
project_dir: /home/me/workspace/another_project

# List of splits.
splits:
  - prefix: "src/partA"
    target: "https://${GH_TOKEN}@github.com/my_company/project-partA.git"
  - prefix: "src/partB"
    target:
      # You can push the split to several repositories
      - "https://${GH_TOKEN}@github.com/my_company/project-partB.git"
      - "https://${GH_TOKEN}@github.com/my_company/project-partZ.git"
  - prefix:
      # You can use several prefix in the split
      - "src/subTree/PartC"
      - "src/subTree/PartZ"
    target: "https://${GH_TOKEN}@github.com/my_company/project-partC.git"

# List of references to split (defined as regexp)
origins:
  - ^master$
  - ^develop$
  - ^feature/
  - ^v\d+\.\d+\.\d+$

Split your repo manualy

With a github token:

$ docker run --rm -ti -e GH_TOKEN -v /cache:/cache/gitsplit -v $PWD:/srv jderusse/gitsplit

With ssh agent:

$ docker run --rm -ti -e SSH_AUTH_SOCK=/ssh-agent -v $SSH_AUTH_SOCK:/ssh-agent -v /cache:/cache/gitsplit -v $PWD:/srv jderusse/gitsplit

Sample with drone.io

Beware, the container have to push on your splited repository. It could be a security issue. Use environments variables as defined in the official documentation

# .gitsplit.yml
cache_dir: "/cache/gitsplit"
splits:
  - prefix: "src/partA"
    target: "https://${GH_TOKEN}@github.com/my_company/project-partA.git"
  - prefix: "src/partB"
    target: "https://${GH_TOKEN}@github.com/my_company/project-partB.git"
  - prefix: "src/subTree/PartC"
    target: "https://${GH_TOKEN}@github.com/my_company/project-partC.git"

origins:
  - ^master$
  - ^develop$
# .drone.yml
pipeline:
  split:
    image: jderusse/gitsplit
    pull: true
    volumes:
      # Share a cache mounted in the runner
      - /drone/cache/gitsplit:/cache/gitsplit

      # Use ssh key defined in the runner
      - /drone/env/gitsplit.ssh:/root/.ssh/
    commands:
      # have to fetch remote branches
      - git fetch
      - gitsplit

Sample with Travis CI

Beware, the container have to push on your splited repository. It could be a security issue. Use environments variables as defined in the official documentation

# .gitsplit.yml
cache_dir: "/cache/gitsplit"
splits:
  - prefix: "src/partA"
    target: "https://${GH_TOKEN}@github.com/my_company/project-partA.git"
  - prefix: "src/partB"
    target: "https://${GH_TOKEN}@github.com/my_company/project-partB.git"
  - prefix: "src/subTree/PartC"
    target: "https://${GH_TOKEN}@github.com/my_company/project-partC.git"

origins:
  - ^master$
  - ^develop$
# .travis.yml
sudo: required
services:
  - docker
cache:
  directories:
    - /cache/gitsplit
install:
  - docker pull jderusse/gitsplit

  # update local repository. Because travis fetch a shallow copy
  - git config remote.origin.fetch "+refs/*:refs/*"
  - git config remote.origin.mirror true
  - git fetch --unshallow

script:
  - docker run --rm -t -e GH_TOKEN -v /cache/gitsplit:/cache/gitsplit -v ${PWD}:/srv jderusse/gitsplit --ref "${TRAVIS_BRANCH}"

Sample with GitLab CI/CD

Beware, the container have to push on your splited repository. It could be a security issue. Use environments variables as defined in the official documentation GitLab SSH Deploy keys.

Note: I highly recommend to use ssh instead of https because of the username/password or username/token. Deploy keys are much easier to use with GitLab

# .gitsplit.yml
cache_dir: "cache/gitsplit"
splits:
  - prefix: "src/partA"
    target: "[email protected]:my_company/project-partA.git"
  - prefix: "src/partB"
    target: "[email protected]:my_company/project-partB.git"
  - prefix: "src/subTree/PartC"
    target: "[email protected]:my_company/project-partC.git"

origins:
  - ^master$
  - ^develop$
# .gitlab-ci.yml with Docker runners
stages:
  - split

split:
  image: jderusse/gitsplit
  stage: split
  cache:
    key: "$CI_JOB_NAME-$CI_COMMIT_REF_NAME"
    paths:
      - cache/gitsplit
  variables:
    GIT_STRATEGY: clone
  before_script:
    - eval $(ssh-agent -s)
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
    - ssh-add -l
  script:
    - git config remote.origin.fetch "+refs/*:refs/*"
    - git config remote.origin.mirror true
    - git fetch
    - gitsplit --ref "${CI_COMMIT_REF_NAME}"

docker-gitsplit's People

Contributors

curry684 avatar jderusse avatar marchagen avatar nervo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.