I’m having trouble with my CI/CD pipeline. Everything works fine when I connect to my server from my local machine. I can use SSH to access GitHub without any problems. But when I try to use GitHub Actions, I keep getting a ‘Permission denied (publickey)’ error.
Here’s what my GitHub Actions workflow looks like:
name: Deploy to DigitalOcean
on:
push:
branches: [main]
pull_request:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Deploy via SSH
uses: remoteexec/ssh-action@v1
with:
host: ${{ secrets.DO_HOST }}
user: ${{ secrets.DO_USER }}
key: ${{ secrets.DO_KEY }}
port: ${{ secrets.DO_PORT }}
script: |
cd ~/myapp
git pull origin main
npm run build
pm2 restart myapp
When I check for SSH identities on the server through my local machine, I see my key. But when I do the same through GitHub Actions, it says there are no identities.
My server is on a DigitalOcean droplet running Ubuntu 20.04. Any ideas on how to fix this SSH key issue in my GitHub Actions workflow?