name: deploy

on:
  workflow_call:
    secrets:
      USER_AUTH:
        required: true

jobs:
  deploy:
    runs-on: prox-1
    steps:
      - name: Restart NextJS service
        env:
          SUDO_PASSWORD: ${{ secrets.USER_AUTH }}
        run: echo "$SUDO_PASSWORD" | sudo -S systemctl restart nextjs.service

      - name: Reload systemd daemon
        env:
          SUDO_PASSWORD: ${{ secrets.USER_AUTH }}
        run: echo "$SUDO_PASSWORD" | sudo -S systemctl daemon-reload

      - name: Check service status
        env:
          SUDO_PASSWORD: ${{ secrets.USER_AUTH }}
        run: echo "$SUDO_PASSWORD" | sudo -S systemctl status nextjs.service --no-pager
