Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can mirror-action be used for a pull vs push? #8

Open
connecteev opened this issue Aug 22, 2020 · 6 comments
Open

Can mirror-action be used for a pull vs push? #8

connecteev opened this issue Aug 22, 2020 · 6 comments
Labels
question Further information is requested

Comments

@connecteev
Copy link

@spyoungtech first off thanks for this useful project. Is it possible to use this to mirror a repo as a "Pull" rather than a "Push"?

My understanding is as such:

  • The mirror-action yml file needs to be added to a local repo A (that you own), and the action would "push" all branches from your local repo A to your remote repo B (on github, gitlab, bitbucket, what have you).

Can this action be used to "pull" instead? The situation is as such: I have read-only access to a private github repo, and I would like to mirror all branches from that repo into one I own and control. If it's possible, what would the yml config look like?

So far I was trying to use https://github.com/actions/checkout but I probably didnt end up configuring it right. A search led me to your repo.

@spyoungtech
Copy link
Member

Hi @connecteev this is a great suggestion. I think it's possible to use this project to do this with /actions/checkout (v1) to checkout the non-github repo, but specifying the REMOTE for mirror-action as the github repository.

This sounds like it'd be a common use-case for folks, so I'll try to figure out exactly how to do it and provide an example yml in the README :)

@connecteev
Copy link
Author

Thanks @spyoungtech In my case, both the source and destination (REMOTE) repos are on github.
Source: private github repo that I have read-only access to
Destination: private github repo that I own (and have write access to)

I want to be able to mirror / sync all branches from the source to the destination. An example yml would be helpful.

@spyoungtech
Copy link
Member

spyoungtech commented Aug 24, 2020

Understood. For this purpose, you'll probably need to use a personal access token (PAT) with the checkout@v1 action like so

- uses: actions/checkout@v1
  with:
    repository: myAccount/my-read-only-repository
    token: ${{ secrets.GitHub_PAT }} # `GitHub_PAT` is a secret contains your PAT.

Then the following step, use this repo's parameters as normal, specifying the present repository as the remote. For example

- uses: spyoungtech/[email protected]
  with:
    REMOTE: [email protected]/myAccount/my-repo.git
    GIT_SSH_PRIVATE_KEY: ${{ secrets.GIT_SSH_PRIVATE_KEY }}
    GIT_SSH_PUBLIC_KEY: ${{ secrets.GIT_SSH_PUBLIC_KEY }}
    GIT_SSH_NO_VERIFY_HOST: "true" # or specify GIT_SSH_KNOWN_HOSTS, recommended

Just be cautious that mirror-action is capable of triggering other GitHub actions, unless you use GITHUB_TOKEN to avoid recursive triggering of actions or a third repo that merely contains the action that could run on a schedule.

@connecteev
Copy link
Author

That is super helpful..thanks so much @spyoungtech! I'll give this a go shortly and report back if I have any issues. Much appreciated.

@spyoungtech spyoungtech added the question Further information is requested label Nov 13, 2020
@nascifMode
Copy link

Note that if the source repository is not in GitHub, you won't be able to use actions/checkout to read from it. According to this issue, it does not support arbitrary remote repositories like mirror-action does.
It would really be awesome if mirror-action was able to support this scenario, when you want to mirror external content into a GitHub mirror.

@Malix-Labs
Copy link

Malix-Labs commented Aug 10, 2024

Are there any updates about this ?

Even if it would require running a CRON job

Found this : https://github.com/thamognya/mirror-git-repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants