repo-sync / repo-sync Goto Github PK
View Code? Open in Web Editor NEW๐ Keep a pair of GitHub repos in sync
License: MIT License
๐ Keep a pair of GitHub repos in sync
License: MIT License
Is it actually required that both repositories need to have the GitHub Actions
script for this to work?
I would believe so if updates are being carried out to each one, but this question is aimed towards one-way updates.
After authenticating and filling out the form, I see the following message:
There was an error creating the workflow, please manually create it in
zeke/test-private
.
And I see this in the browser console:
main.9cb8cd7a.chunk.js:69 Error: 404 error making request put https://api.github.com/repos/zeke/test-private/contents/.github/workflows/repo-sync.yml: "Not Found"
at new t (Requestable.js:110)
at Requestable.js:434
Here's a screenshot:
I will try to recreate this error locally in development.
cc @wei
With the introduction of Secrets API, we should update the interactive installation page to create secrets automatically.
cc/ @zeke
Using two Heroku buildpacks for (1) project in a subdirectory (2) create-react-app
heroku buildpacks:clear -a github-repo-sync
heroku buildpacks:set https://github.com/timanovsky/subdir-heroku-buildpack -a github-repo-sync
heroku buildpacks:add mars/create-react-app -a github-repo-sync
heroku config:set PROJECT_PATH=sync -a github-repo-sync
Sample workflow file
name: "Sync wei/pull:master to pull"
on:
schedule:
- cron: "*/60 * * * *"
jobs:
repo-sync:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: repo-sync/github-sync@v1
name: repo-sync
env:
SOURCE_REPO: "wei/pull"
SOURCE_BRANCH: "master"
DESTINATION_BRANCH: "pull"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: $SOURCE_REPO $SOURCE_BRANCH:$DESTINATION_BRANCH
As discussed, the workflow file will reside in the destination repository (for our use-case, a workflow file will exist in each repository). The workflow in the destination repository has write access through the built-in secrets.GITHUB_TOKEN
.
Cron is a way to allow maximum flexibility in the server/host and permission of the source repo. Repository dispatch event would be a great way to trigger the workflow when source repository sees a push action, but the request data and format of Github's built-in webhooks is quite different from what Repository dispatch event call takes in, therefore, a middleware/webhook proxy/or an action could to be setup to support this use-case in the future. But for now we are opting for a cron job every 15 minutes. If no updates were found, the job will succeed silently without taking action.
There are two ways to use sync, unidirectional and bidirectional.
owner/repoA:master โ owner/repoB:master
Configuration variables can be put directly in workflow yaml.
ps. setup for bidirectional flow (using secrets) will also work with unidirectional flow.
repoB/.github/workflows/sync.yml
name: Sync repository
on:
schedule:
- cron: "*/15 * * * *"
jobs:
repo-sync:
name: Sync repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: wei/github-sync@v1
name: Sync repository to branch
env:
SOURCE_REPO: "owner/repoA"
SOURCE_BRANCH: "master"
DESTINATION_BRANCH: "from-repoA"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: $SOURCE_REPO $SOURCE_BRANCH:$DESTINATION_BRANCH
- uses: wei/pull-request@v1
name: Create pull request
env:
SOURCE_BRANCH: "from-repoA"
DESTINATION_BRANCH: "master"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
owner/repoA:master โ owner/repoB:master
For bidirectional use-cases, because master branches are synced, the workflow yaml file will be the same between repoA and repoB. Because of this, the values of those variables need to be kept separately from the codebase. However, there is no easy way to store key value pairs that is tied to a repository except for the recently introduced Secrets
. Therefore, that is the route I've chosen for now.
repoA/settings/secrets
SOURCE_REPO=owner/repoB
SOURCE_BRANCH=master
DESTINATION_BRANCH=from-repoB
PR_DESTINATION_BRANCH=master
repoB/settings/secrets
SOURCE_REPO=owner/repoA
INTERMEDIATE_BRANCH=from-repoA
repoA/.github/workflows/sync.yml
AND repoB/.github/workflows/sync.yml
name: Sync repository
on:
schedule:
- cron: "*/15 * * * *"
jobs:
repo-sync:
name: Sync repository
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: wei/github-sync@v1
name: Sync repository to branch
env:
SSH_PRIVATE_KEY: ${{ secrets.SOURCE_REPO_PRIVATE_KEY }}
SOURCE_REPO: ${{ secrets.SOURCE_REPO }}
SOURCE_BRANCH: "master"
INTERMEDIATE_BRANCH: ${{ secrets.INTERMEDIATE_BRANCH }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
args: $SOURCE_REPO $SOURCE_BRANCH:$INTERMEDIATE_BRANCH
- uses: wei/pull-request@v1
name: Create pull request
env:
SOURCE_BRANCH: ${{ secrets.INTERMEDIATE_BRANCH }}
DESTINATION_BRANCH: "master"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Any feedback/suggestions on this flow and using secrets to store config variables?
GITHUB_TOKEN Permissions
Contents: read
Metadata: read
Packages: read
Run repo-sync/github-sync@v2
with:
source_repo: ***
source_branch: ***
destination_branch: ***
/usr/bin/docker run --name ghcrioreposyncgithubsyncv230_da0760 --label ed866e --workdir /github/workspace --rm -e "INPUT_SOURCE_REPO" -e "INPUT_SOURCE_BRANCH" -e "INPUT_DESTINATION_BRANCH" -e "INPUT_GITHUB_TOKEN" -e "INPUT_SYNC_TAGS" -e "GITHUB_TOKEN" -e "SYNC_TAGS" -e "HOME" -e "GITHUB_JOB" -e "GITHUB_REF" -e "GITHUB_SHA" -e "GITHUB_REPOSITORY" -e "GITHUB_REPOSITORY_OWNER" -e "GITHUB_REPOSITORY_OWNER_ID" -e "GITHUB_RUN_ID" -e "GITHUB_RUN_NUMBER" -e "GITHUB_RETENTION_DAYS" -e "GITHUB_RUN_ATTEMPT" -e "GITHUB_REPOSITORY_ID" -e "GITHUB_ACTOR_ID" -e "GITHUB_ACTOR" -e "GITHUB_TRIGGERING_ACTOR" -e "GITHUB_WORKFLOW" -e "GITHUB_HEAD_REF" -e "GITHUB_BASE_REF" -e "GITHUB_EVENT_NAME" -e "GITHUB_SERVER_URL" -e "GITHUB_API_URL" -e "GITHUB_GRAPHQL_URL" -e "GITHUB_REF_NAME" -e "GITHUB_REF_PROTECTED" -e "GITHUB_REF_TYPE" -e "GITHUB_WORKFLOW_REF" -e "GITHUB_WORKFLOW_SHA" -e "GITHUB_WORKSPACE" -e "GITHUB_ACTION" -e "GITHUB_EVENT_PATH" -e "GITHUB_ACTION_REPOSITORY" -e "GITHUB_ACTION_REF" -e "GITHUB_PATH" -e "GITHUB_ENV" -e "GITHUB_STEP_SUMMARY" -e "GITHUB_STATE" -e "GITHUB_OUTPUT" -e "RUNNER_OS" -e "RUNNER_ARCH" -e "RUNNER_NAME" -e "RUNNER_TOOL_CACHE" -e "RUNNER_TEMP" -e "RUNNER_WORKSPACE" -e "ACTIONS_RUNTIME_URL" -e "ACTIONS_RUNTIME_TOKEN" -e "ACTIONS_CACHE_URL" -e GITHUB_ACTIONS=true -e CI=true -v "/var/run/docker.sock":"/var/run/docker.sock" -v "/home/runner/work/_temp/_github_home":"/github/home" -v "/home/runner/work/_temp/_github_workflow":"/github/workflow" -v "/home/runner/work/_temp/_runner_file_commands":"/github/file_commands" -v "/home/runner/work/homeassistant-core-mirror/homeassistant-core-mirror":"/github/workspace" ghcr.io/repo-sync/github-sync:v2.3.0 "" ":***"
Set the GITHUB_TOKEN environment variable.
found via https://github.com/marketplace?type=actions&query=sync , the link goes to https://github.com/marketplace/actions/github-sync which is borked (dunno if thats a problem on this end or on the gh one)
My team is planning to migrate from Bitbucket to Github and we found the github-sync project that does exactly what we need, however, we need to sync between Bitbucket and Github.
Would it be possible to add this feature?
Thanks
Github Actions' GITHUB_TOKEN has push permission to gh-pages but it currently does not trigger a page build. Therefore, for now we are using heroku for hosting.
Hi there,
the README says in section Features that one-way syncs are possible, but this case is not mentioned on the rest of the page.
What would I have to do for a one-way sync? Just adding the workflow file in one repo does not seem to work.
Thanks
Hi Guys, is it possible to sync repos from 2 different organizations/accounts?
thanks a lot
The README mentions:
Your two repos must share a commit history.
I'm confused as to how to set this up exactly; could you provide some details/help for this? Especially for two repos that are already setup (and have commits in them) - I'd love to know how to integrate this to get my repos syncing.
Thanks
Hello,
I'm trying to setup synchronisation between a private and a public repositories, and facing the following issue:
this is unexpected, because changes are already there (with different checksums, though)
I think it could be a problem with my setup and I'm missing some part, could you please help?
We're currently using https://github.com/wei/heroku-buildpack-static -- let's upstream our changes to the canonical repo and use that instead.
Are there any framework preferences as far as frontend project goes? Perhaps a boilerplate that Github uses to kickstart a project?
Also which backend web application / routing framework do you guys prefer?
Thanks!
Currently the link https://help.github.com/en/articles/events-that-trigger-workflows#external-events doesn't resolve to any heading on that document.
I'm guessing it may be referring to something that would use https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#repository_dispatch or https://docs.github.com/en/free-pro-team@latest/actions/reference/events-that-trigger-workflows#workflow_dispatch, but some details would be helpful
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.