on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: docker
    container: ruby:3.4-bookworm
    steps:
      - uses: actions/checkout@v3
      - name: "Setup"
      - run: |
      bundle config set path vendor/bundle
      bundle install --jobs=4 --retry=3
      command -v rsync >/dev/null || ( apt-get update -y && apt-get install rsync -y )
      command -v ssh-agent >/dev/null || ( apt-get update -y && apt-get install openssh-client -y )
      eval $(ssh-agent -s)
      echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
      mkdir -p ~/.ssh
      chmod 700 ~/.ssh
      echo "$SSH_KNOWN_HOSTS" > ~/.ssh/known_hosts
      chmod 644 ~/.ssh/known_hosts
      ./bin/deploy.sh
