Skip to content

Instantly share code, notes, and snippets.

@leonson
Created July 19, 2020 04:06
Show Gist options
  • Save leonson/c937a97ce14aa17f0205c8a7e04ccfc8 to your computer and use it in GitHub Desktop.
Save leonson/c937a97ce14aa17f0205c8a7e04ccfc8 to your computer and use it in GitHub Desktop.
Sample Workflow
on:
push:
branches:
- master
jobs:
deploy-to-digital-ocean-droplet:
runs-on: ubuntu-latest
name: Deploy Website
steps:
- name: Checkout master
uses: actions/checkout@master
- name: Pull from GitHub
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_IP }}
username: ${{ secrets.HOST_USERNAME }}
password: ${{ secrets.HOST_PASSWORD }}
script: cd ~/path/to/project && git pull [email protected]:project/home.git
- name: Docker Build
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.HOST_IP }}
username: ${{ secrets.HOST_USERNAME }}
password: ${{ secrets.HOST_PASSWORD }}
script: cd ~/path/to/project && docker built -t <container> .
...
@chaudharykiran
Copy link

I am using Droplet IP address as host, root as username, my digitalocean password as password. But still it is not working. Any hint?

@leonson
Copy link
Author

leonson commented Aug 20, 2020

root as username, my digitalocean password as password

This combination doesn't look right. You want to use user/password you usually use to login the droplet, not the password you login to digitalocean.com

Also it's dangerous to expose root user in first place. You want to create a different unix user (hint: useradd) rather than root to do the work on your Droplet.

@chaudharykiran
Copy link

chaudharykiran commented Aug 20, 2020

You want to use user/password you usually use to login the droplet.

My droplet don't have password. I am using ssh to login my droplet from my local machine. What to use in this case?

@leonson
Copy link
Author

leonson commented Aug 20, 2020

@chaudharykiran in this case you either useradd or figure out how to configure your GitHub repo to SSH into your Droplet, like you did on your local machine. appleboy/ssh-action may or may not have option.

@ahmedsadman
Copy link

What if I don't use Docker? Can I still use this ssh-action tool?

@leonson
Copy link
Author

leonson commented Aug 26, 2020

@ahmedsadman yes you can.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment