Open mrengy opened 2 years ago
I think you might be able to use one of these https://github.com/marketplace?type=actions&query=ssh+
The workflow might look something like this:
name: Deploy latest main to stage
on:
push:
branches:
- main
jobs:
build:
name: Deploy to Stage
runs-on: ubuntu-latest
steps:
- name: executing remote ssh commands using password
# https://github.com/marketplace/actions/ssh-remote-commands
uses: appleboy/ssh-action@v0.1.6
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
# You might have to cd to the repo and pull here
script: git pull
Ah, yes. Thanks! I think this will get me a lot closer than what I was looking at originally.
Note to self: I may want to generate ssh keys https://help.dreamhost.com/hc/en-us/articles/216499537-How-to-configure-passwordless-login-in-Mac-OS-X-and-Linux and use that rather than my ssh password.
-- Mike Eng (he/him) mike-eng.com linkedin.com/in/mikeeng401
On Jan 2, 2023, at 2:38 PM, Shekhar Khedekar @.***> wrote:
I think you might be able to use one of these https://github.com/marketplace?type=actions&query=ssh+
The workflow might look something like this:
name: Deploy latest main to stage on: push: branches:
- main
jobs: build: name: Deploy to Stage runs-on: ubuntu-latest steps:
- name: executing remote ssh commands using password
https://github.com/marketplace/actions/ssh-remote-commands
uses: @.*** with: host: ${{ secrets.HOST }} username: ${{ secrets.USERNAME }} password: ${{ secrets.PASSWORD }} port: ${{ secrets.PORT }}
You might have to cd to the repo and pull here
script: git pull
— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were assigned.
I tried to do this using an SSH key rather than username / password, but I'm stuck. I generated an id_ed25519 keypair on the server and saved secrets in Github according to these instructions but with a couple of modifications:
With each push, when I look at the action in Github, I'm getting:
Run ssh server pwd ssh server pwd shell: /usr/bin/bash -e {0} Load key "/home/runner/.ssh/server.key": error in libcrypto Permission denied, please try again. Permission denied, please try again. @: Permission denied (publickey,password). Error: Process completed with exit code 255.
I have the following secrets set at the repo level
I think all the repository secrets are correct. To show what these variables are, when I SSH into the server using Terminal, I use the command "ssh SSH_USER
@SSH_HOST
".
And SSH_KEY is the public key I generated on the server - the contents of the file id_ed25519
Also (I didn't use these in the actions file yet, but thought we'd need them for the future) I made a couple of environments and these environment variables.
@shekharkhedekar if you think it's worth the effort, feel free to try and sort this out and let me know if you need anything else. Honestly, I'm not sure if it's worth the effort ;)
You'll need to create a public/private key pair, add the private key to github, and the public key to the remote host - see here https://docs.oracle.com/cd/E19683-01/806-4078/6jd6cjru7/index.html
I got the SSH key to work - swapped them as you recommended. However, the commands I'm trying to run in the action to cd to the stage directory (where I would later pull to main) aren't working. I fiddled with it for a while but couldn't get it right. Seems when it first connects via SSH it's going to the directory /home/runner/work/vanguard-history/vanguard-history
, and trying to change directories to /home/mrengyscv/stage.historyscv
is giving an error. You can see some of the results under various Actions.
I probably spent more time than I should have on this. ;)
For now, once you merge https://github.com/mrengy/vanguard-history/pull/97 , I'll set up a cron job to automatically pull main to stage every 15 mins or so.
I set up "git pull" to run on dev and stage every 5 and 15 mins, respectively. However, the worfklow to compile CSS is running into "npm command not found" on the cronjob. It's weird because it should be using the same user that I use when I SSH in manually - where the compile CSS workflow works. I emailed dreamhost support about this.
https://github.com/marketplace/actions/branch-deploy