Reputation: 1112
I'm using plugins that hosted privately in Github with an ssh access. When running flutter pub get
in Github actions this command fails. I followed a tutorial that uses a deploy key and I tried this:
jobs:
build:
runs-on: ubuntu-18.04
steps:
- uses: actions/checkout@v1
- name: Setup SSH Keys and known_hosts
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: |
mkdir -p ~/.ssh
ssh-keyscan github.com >> ~/.ssh/known_hosts
ssh-agent -a $SSH_AUTH_SOCK > /dev/null
ssh-add - <<< "${{ secrets.SSH_PRIVATE_KEY }}"
- name: Some task that fetches dependencies
env:
SSH_AUTH_SOCK: /tmp/ssh_agent.sock
run: flutter pub get
also tried:
- uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Fetch flutter dependencies
run: flutter pub get
But the command still fails. What am I doing wrong and is there another way to make this command fetch private keys?
Upvotes: 2
Views: 2624
Reputation: 96
You can use this action to add your ssh key.
https://github.com/marketplace/actions/install-ssh-key
Insert the private key and the known hosts in the secrets of your repository.
NOTE: OPENSSH format (key begins with -----BEGIN OPENSSH PRIVATE KEY-----) may not work due to OpenSSH version on VM. Please use PEM format (begins with -----BEGIN RSA PRIVATE KEY-----) instead. In order to convert your key inline to PEM format simply use ssh-keygen -p -m PEM -f ~/.ssh/id_rsa.
You can get the known hosts using:
ssh-keyscan github.com
After this add the ssh in your workflow:
- uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH }}
name: id_rsa
known_hosts: ${{ secrets.KNOWN_HOSTS }}
I hope this can help you
Upvotes: 7