I want to copy a github code repository from organization A to organization B. If any PR is merged in master branch of organization A then same PR/changes must reflect in organization B master branch.
For this to work I used github action. Following is the workflow for the action:
name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run a one-line script
run: |
git remote add orgb https://${{ secrets.GIT_ACCESS_TOKEN }}@github.com/orgb/backend.git
git remote -v
git fetch orgb
git push -f orgb $GITHUB_SHA:main
But I am getting following error
remote: Repository not found.
fatal: repository 'https://github.com/orgb/backend.git/' not found
Error: Process completed with exit code 128.
The same steps works locally.
When added a step
- name: Checkout backend from orgb
uses: actions/checkout@v3
with:
repository: orgb/backend
path: backend
token: <token>
Then the job step is executing it
How to solve this?
Also When used https://github.com/marketplace/actions/mirroring-repository Got this error:
Load key "/github/home/.ssh/id_rsa": invalid format
debug1: No more authentication methods to try.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Which git hooks will be helpful? What other approach should be followed?