1

I am trying to deploy to aptible with github actions. This is my .yml file

name: Cartwheel Staging CI
run-name: ${{ github.actor }} activated these GitHub Actions

on:
  pull_request:
    branches: [ staging ]

env:
  APTIBLE_ENVIRONMENT: ${{ secrets.APTIBLE_ENVIRONMENT }}
  APTIBLE_APP: ${{ secrets.APTIBLE_STAGING_APP }}


 jobs:
 

 deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          fetch-depth: 0
      - uses: webfactory/ssh-agent@v0.5.4
        with:
          ssh-private-key: ${{ secrets.APTIBLE_GIT_SSH_KEY }}
      - name: Deploy to Aptible
        run: |
          ssh-keyscan beta.aptible.com >> ~/.ssh/known_hosts
          git remote add staging git@beta.aptible.com:${APTIBLE_ENVIRONMENT}/${APTIBLE_STAGING_APP}.git
          git push staging ${GITHUB_SHA}:main

I have saved the APTIBLE_GIT_SSH_KEY as described in webfactory/ssh-agent README.

This is the actual error I receive in my github actions:

Run webfactory/ssh-agent@v0.5.4
  with:
    ssh-private-key: ***
  env:
    APTIBLE_ENVIRONMENT: ***
    APTIBLE_APP: ***
Adding GitHub.com keys to /home/runner/.ssh/known_hosts
Starting ssh-agent
SSH_AUTH_SOCK=/tmp/ssh-XXXXXXRcccK6/agent.1720
SSH_AGENT_PID=1721
Adding private key(s) to agent
Error loading key "(stdin)": error in libcrypto
Error: Command failed: ssh-add -
Error loading key "(stdin)": error in libcrypto
garthcodes
  • 91
  • 1
  • 6

2 Answers2

2

The error wasn't constructive so it took me a while to figure out what I did wrong.

I saved my public key in GitHub secrets.

I changed it to my private key and the error is gone.

garthcodes
  • 91
  • 1
  • 6
1

I got to a remote repo via SSH using Github actions by making a separate step to create an SSH file from Github secrets.

- name: Create SSH key
  env:
    SSH_PRIVATE_KEY: ${{secrets.SSH_PRIVATE_KEY}}
  run: |
    echo "$SSH_PRIVATE_KEY" > private.key
    sudo chmod 400 private.key

Then using the private key file later

- name: Docker Dependencies
  run: |
    eval `ssh-agent -s`
    ssh-add private.key
    docker compose -f docker/docker-compose-test.yml -p my-project up

The key file needs to be cleaned up after.

rupweb
  • 3,052
  • 1
  • 30
  • 57