Skip to content
This repository was archived by the owner on Nov 18, 2021. It is now read-only.
This repository was archived by the owner on Nov 18, 2021. It is now read-only.

Automatically mirror an external repository by pulling at regular intervals (daily) #415

Open

Description

@cirosantilli

I want to take an arbitrary Git clone URL, give it to GitHub when creating a new repository, and have GitHub git pull the repository regularly, e.g. daily.

This would allow me to use GitHub's superior analysis features like contributor analysis and clean permalink URLs which other web interfaces do not have, so I can analyze projects which interest me but for which I do not control hooks.

Such repositories could even be "read only", such that the only update possible would be the daily pull, e.g. user pushes are forbidden. This way GitHub does not need to use so much storage.

You could even consider a magic username like mirrors to which those clones would be added, to provide a canonical mirror for each URL.

On the upside for GitHub, you'd get more traffic by using good content from other projects.

Non-git imports like mercurial and SVN would be great as well.

I basically want to make the magic on request "mirrored on" feature of https://github.com/gcc-mirror/gcc available for anyone.

Related help pages:

Activity

  1. andrewfenn commented on Mar 17, 2016

    @andrewfenn

    I also want this feature but for different reasons:

    • I want to be able to pull a HG repo on bitbucket at set time periods.
    • I want to be able to still write to the repo so I can setup travis CI, etc.
    • I want all merge conflicts that break the auto merging to email me and stop the process until it's fixed

    By having this feature I can avoid HG and Bitbucket while still being able to follow up on open source project's upstream fork that still does use it.

  2. TPS commented on Jul 5, 2016

    @TPS
    Collaborator
  3. jamiecarl commented on Jul 11, 2016

    @jamiecarl

    I wouldn't mind having this feature as well, but instead of at a specified interval (although that would be fine) it would be cool to have some sort of reverse webhook. I develop locally using GitLab but push to GitHub to cater for a bunch of picky lovely users. GitLab does webhooks so it would be nice to use that to tickle a project URL at Github to get it to pull my repository just like it did when I set it up initially,

  4. cirosantilli commented on Jul 11, 2016

    @cirosantilli
    CollaboratorAuthor

    @JAZ-013 I agree that would be cool. Open a separate issue for it.

  5. jamiecarl commented on Aug 2, 2016

    @jamiecarl
  6. TPS commented on Aug 2, 2016

    @TPS
    Collaborator
  7. stuartpb commented on Nov 13, 2017

    @stuartpb

    Looping in this Stack Overflow question about how GitHub used to do this, but no longer does.

  8. theAkito commented on Mar 21, 2019

    @theAkito

    4 years and still open. Sad.

  9. added
    cross referencing
    automation
    on Mar 22, 2019
  10. smorimoto commented on Nov 3, 2019

    @smorimoto
  11. hle-iad commented on Dec 4, 2019

    @hle-iad
  12. SamWhited commented on Dec 4, 2019

    @SamWhited

    Please don't +1, you're spamming others who follow this issue. Add an upvote using reactions. That said:

    Can this be closed now that actions exist? Something like this should work after you import the repo if you put itin .github/workflows/mirror.yml or similar. Be sure to replace $REPO with the URL you want to clone:

    name: Mirror Repo
    on:
      schedule:
        # nightly (0th hour 0th minute of every day)
        - cron:  '0 0 * * *'
    
    jobs:
      build:
        runs-on: ubuntu-latest
        steps:
        - name: Mirror
          run: |
            git clone --mirror '$REPO'
            cd mux.git/
            git remote add github "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.git"
            git push --mirror github
          env:
            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    If you can't add files to the Repo in question, create a new repo that just contains GitHub actions for mirroring other repos and give it access to deploy keys for each repo it will mirror as secrets.

  13. theAkito commented on Dec 4, 2019

    @theAkito
  14. theAkito commented on Dec 4, 2019

    @theAkito
  15. username7171 commented on Jan 29, 2021

    @username7171

    Please don't +1, you're spamming others who follow this issue. Add an upvote using reactions. That said:

    Can this be closed now that actions exist? Something like this should work after you import the repo if you put itin .github/workflows/mirror.yml or similar. Be sure to replace $REPO with the URL you want to clone:

    name: Mirror Repo
    on:
      schedule:
        # nightly (0th hour 0th minute of every day)
        - cron:  '0 0 * * *'
    
    jobs:
      build:
        runs-on: ubuntu-latest
        steps:
        - name: Mirror
          run: |
            git clone --mirror '$REPO'
            cd mux.git/
            git remote add github "https://$GITHUB_ACTOR:[email protected]/$GITHUB_REPOSITORY.git"
            git push --mirror github
          env:
            GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

    If you can't add files to the Repo in question, create a new repo that just contains GitHub actions for mirroring other repos and give it access to deploy keys for each repo it will mirror as secrets.

    This is for GitHub repo pushing to some GitHub repo.
    And you are saying if we want some GitHub repo to be pulling from some GitLab repo, we have to create an extra repo in GitHub. This is not that convenient. GitLab natively supports pushing and pull without creating any extra repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    automationcross referencingenhancementpull-requests

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions