Requirements:
- DigitalOcean Droplet (Ubuntu 20.04+) should be created
- Github repository
- 
ssh root@DROPLET_IP
- 
sudo vi /etc/ssh/sshd_config
- 
change PasswordAuthenticationfromnotoyes
- 
sudo systemctl restart ssh
- 
adduser deployer
- 
usermod -aG sudo deployer
- 
exit
- 
ssh deployer@DROPLET_IP
- 
ssh-keygen
- 
ssh-keyscan -t rsa github.com >> ~/.ssh/known_hosts
- 
cat ~/.ssh/id_rsa.puband copy the output
- 
go to https://github.com/settings/ssh/new and paste your id_rsa.pubvalue
- 
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
- 
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys2
- 
chmod 700 ~/.ssh/authorized_keys && chmod 640 ~/.ssh/authorized_keys2
- 
go to and create a new secrets in repository settings page: https://github.com/USERNAME/REPOSITORY/settings/secrets/actions/new: 
- 
secret name: HOST, secret value: YOUR_DROPLET_IP 
- 
secret name: USERNAME, secret value: deployer 
- 
copy value from cat ~/.ssh/id_rsaand paste it as a new secret name: KEY, secret value: PASTE_YOUR_VALUE_HERE
Create a new file in your repository .github/workflows/on-main-push-deploy-do.yml and add following:
name: Deploy to DigitalOcean Droplet
'on':
  push:
    branches:
      - main
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - name: Deploy to DigitalOcean Droplet
        uses: appleboy/ssh-action@master
        with:
          host: ${{secrets.HOST}}
          username: ${{secrets.USERNAME}}
          key: ${{secrets.KEY}}
          script: |
            export NVM_DIR=~/.nvm
            source ~/.nvm/nvm.sh
            rm -rf test
            mkdir test
            cd test
            git clone [email protected]:username/projectname
            echo 'Deployment to digital ocean finished'
Commit and push to the remote repository and go check out the ACTIONS tab for the jobs.
YOUR_DROPLET_ID -> YOUR_DROPLET_IP?