on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: docker
    container: timbru31/ruby-node:3.4-22
    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
      - name: "Deploy"
      - run: "./bin/deploy.sh"
