wei / git-sync

🔃 A GitHub Action for syncing between two independent repositories using force push
254 stars 124 forks source link

Trying to understand variable configuration #1

Closed phillamb168 closed 4 years ago

phillamb168 commented 4 years ago

Hi, here's a snippet of my implementation of this action: - name: repo-sync uses: wei/git-sync@v1 env: SOURCE_REPO: "git@github.com:hopeonesource/hopeonesource.org.git" SOURCE_BRANCH: ${ GITHUB_REF:11 } DESTINATION_REPO: "codeserver.dev.[redacted]@codeserver.dev.[redacted].drush.in:2222/~/repository.git" DESTINATION_BRANCH: ${ GITHUB_REF:11 } SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY_PANTHEON_REMOTE }} with: args: $SOURCE_REPO $SOURCE_BRANCH $DESTINATION_REPO $DESTINATION_BRANCH

The secret exists, however I am getting both a Permission Denied (public key) message as well as the following:

SOURCE=git@github.com:repo/repo.git:${ DESTINATION=git@github.com:GITHUB_REF:11.git:} Warning: Permanently added 'github.com,140.82.114.4' (RSA) to the list of known hosts. git@github.com: Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists. error: src refspec ${ does not match any error: failed to push some refs to 'git@github.com:GITHUB_REF:11.git'

[error]Docker run failed with exit code 1

What am I doing wrong? It's tough to find documentation on how env vars are supposed to be referenced.

rasodu commented 4 years ago

Both, source and destination, repositories are synced over SSH protocols. Currently you are only allowed to add a single SSH_PRIVATE_KEY. So, you are trying to use the same private key to read repo from github and to push repo to codeserver. You have got a few options to fix this.

  1. Add your public key to "Deploy key" on your Github project.
  2. Use this as your source: https://$GITHUB_TOKEN@github.com/hopeonesource/hopeonesource.org.git <- I haven't tried this. So, not hundred percent sure that this will work as is. May be there is a few more changes that you would need.
  3. Create a pull request that will allow using two different keys. One for source repo and second for destination repo.

Let us know what was final solution.