Home > database >  How to pull in additional private repositories in Amplify
How to pull in additional private repositories in Amplify

Time:05-27

Trying to use AWS Amplify to deploy a multi-repo dendron wiki which has a mix of public and private github repositories.

Amplify can be associated with a single repo but there doesn't seem to be a built-in way to pull in additional private repositories.

CodePudding user response:

  1. Create a custom deploy key for the private repo in github
    • generate the key
    ssh-keygen -f deploy_key -N ""
    
  2. Encode the deploy key as a base64 encoded env variable for amplitude
    cat deploy_key | base64 | tr -d \\n 
    
  3. Modify the amplify.yml file to make use of the deploy key
    • there's 2 key steps
      • adding deploy key to ssh-agent
        • WARNING: this implementation will print the $DEPLOY_KEY to stdout
      • disabling StrictHostKeyChecking
        • NOTE: amplify does not have a $HOME/.ssh folder by default so you'll need to create one as part of the deployment process
    • relevant excerpt below
    - ...
    - eval "$(ssh-agent -s)"
    - ssh-add <(echo "$DEPLOY_KEY" | base64 -d)
    
    - echo "disable strict host key check"
    - mkdir ~/.ssh
    - touch ~/.ssh/config
    
    - 'echo -e "Host *\n\tStrictHostKeyChecking no\n\n" > ~/.ssh/config'
    - ...
    
    • full build file here

Now you should be able to use git to clone the private repo.

For a more detailed writeup as well as alternatives and gotchas, see here

  • Related