Posted on :: Tags: , ,

Everything I need to not forget.

Digital Ocean

Droplet Creation

Create a Droplet with Docker already installed. Add an ssh key to the droplet, during creation already.

To authenticate: Go to GitHub → Settings → Developer Settings → Personal Access Tokens (Classic) Create a token with repo permissions. Configure git to use the token for authentication:

git config --global credential.helper store

And then clone a repository, and enter the username and PAT.

Neovim, Lazyvim

sudo apt update
sudo apt install neovim
sudo apt install build-essential
sudo apt install libstdc++6
gcc --version

mv ~/.config/nvim{,.bak}
git clone https://github.com/LazyVim/starter ~/.config/nvim
rm -rf ~/.config/nvim/.git
nvim

Github Actions

Secrets

Go to Settings -> Secrets and variables -> Actions -> New repository secret, and add the following secrets:

  • DIGITAL_OCEAN_DROPLET_IP
  • DIGITALOCEAN_SSH_PRIVATE_KEY
  • DIGITALOCEAN_SSH_USER (root for personal use, otherwise create a new user)
  • SSH_PASSWORD (If the local ssh key is password protected, otherwise leave it empty)

Action

Whenever something gets pushed to main, it gets pulled to opt/thesis in the droplet. I used this action for some containers I was running for data-scraping for my thesis, hence the directory name. It then builds and gets the compose containers up, with environment variable PRODUCTION_ENV = True.

name: Deploy to DigitalOcean

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Deploy via SSH
        uses: appleboy/ssh-action@v1.0.0
        with:
          host: ${{ secrets.DIGITALOCEAN_DROPLET_IP }}
          username: ${{ secrets.DIGITALOCEAN_SSH_USER }}
          key: ${{ secrets.DIGITALOCEAN_SSH_PRIVATE_KEY }}
          passphrase: ${{ secrets.SSH_PASSWORD }}
          script: |
            cd /opt/thesis
            git pull origin main
            PRODUCTION_ENV=True docker compose up -d --build