name: Deploy Blog
on:
  push:
    branches: [main]
jobs:
  deploy:
    runs-on: ubuntu-latest
    container: node:18
    steps:
      - uses: actions/checkout@v3
      - run: npm install
      - run: npm run build:posts
      - run: npm run build
      - run: |
          echo "${{ secrets.VPS_DEPLOY_USER_SSH_KEY }}" > /tmp/ssh_key
          chmod 600 /tmp/ssh_key
          ssh -i /tmp/ssh_key -o StrictHostKeyChecking=no ${{ vars.VPS_DEPLOY_USER }} "bash -c 'rm -rf /var/www/systemsobscure.blog/*'"
          scp -i /tmp/ssh_key -o StrictHostKeyChecking=no -r dist/* ${{ vars.VPS_DEPLOY_USER }}:/var/www/systemsobscure.blog/
          rm /tmp/ssh_key
