name: Deploy Site

on:
  push:
    branches:
      - master

jobs:
  deploy:
    runs-on: docker

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

      - name: Install Make and rsync
        run: |
          apt-get update
          apt-get install -y make rsync

      - name: Add Deploy Key to SSH
        run: |
          mkdir ~/.ssh
          echo "$SSH_KEY" >> ~/.ssh/id_ed25519_deployer
          chmod 400 ~/.ssh/id_rsa_embroideryviewer
          echo -e "Host deployer\n\tUser deployer\n\tHostname 45.76.5.44\n\tIdentityFile ~/.ssh/id_ed25519_deployer\n\tStrictHostKeyChecking No" >> ~/.ssh/config

      - name: Install Hugo
        run: |
          wget https://github.com/gohugoio/hugo/releases/download/v0.145.0/hugo_0.145.0_linux-amd64.deb
          dpkg -i hugo_0.145.0_linux-amd64.deb

      - name: Run Make Deploy
        run: |
          make deploy
