Can mirror-action be used for a pull vs push?
Opened this issue · 6 comments
@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.
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 :)
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.
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/mirror-action@v0.4.0
with:
REMOTE: git@github.com/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.
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.
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.
Are there any updates about this ?
Even if it would require running a CRON job
Found this : https://github.com/thamognya/mirror-git-repo