Code Monkey home page Code Monkey logo

git-mirror-action's Introduction

Git Mirror Action

A GitHub Action for mirroring a git repository to another location via SSH.

Inputs

source-repo

Required SSH URL of the source repo.

destination-repo

Required SSH URL of the destination repo.

dry-run

Optional (default: false) Execute a dry run. All steps are executed, but no updates are pushed to the destination repo.

Environment variables

SSH_PRIVATE_KEY: Create a SSH key without a passphrase which has access to both repositories. On GitHub you can add the public key as a deploy key to the repository. GitLab has also deploy keys with write access and for any other services you may have to add the public key to your personal account.
Store the private key as an encrypted secret and use it in your workflow as seen in the example workflow below.

SSH_KNOWN_HOSTS: Known hosts as used in the known_hosts file. StrictHostKeyChecking is disabled in case the variable isn't available.

If you added the private key or known hosts in an environment make sure to reference the environment name in your workflow otherwise the secret is not passed to the workflow.

Example workflow

name: Mirror to Bitbucket Repo

on: [ push, delete, create ]

# Ensures that only one mirror task will run at a time.
concurrency:
  group: git-mirror

jobs:
  git-mirror:
    runs-on: ubuntu-latest
    steps:
      - uses: wearerequired/git-mirror-action@v1
        env:
          SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
          SSH_KNOWN_HOSTS: ${{ secrets.SSH_KNOWN_HOSTS }}
        with:
          source-repo: "[email protected]:wearerequired/git-mirror-action.git"
          destination-repo: "[email protected]:wearerequired/git-mirror-action.git"

Docker

docker run --rm -e "SSH_PRIVATE_KEY=$(cat ~/.ssh/id_rsa)" $(docker build -q .) "$SOURCE_REPO" "$DESTINATION_REPO"

License

The Dockerfile and associated scripts and documentation in this project are released under the MIT License.

git-mirror-action's People

Contributors

andersonaddo avatar klausi avatar mizuka-wu avatar ocean90 avatar offa avatar yikun 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.