name: Deploy Systems
on: [workflow_dispatch]

jobs:
  deploy:
    runs-on: nix
    steps:
      - uses: https://git.madhouse-project.org/actions/nix/setup@v2
        with:
          nix_path: nixpkgs=flake:nixpkgs

      - uses: https://git.madhouse-project.org/actions/nix/build@v2
        with:
          flake: .
          targets: |
            nixosConfigurations

      - uses: https://git.madhouse-project.org/actions/nix/deploy-rs@v2
        with:
          ssh_user: ${{ secrets.SSH_USER }}
          ssh_key: ${{ secrets.SSH_PRIVATE_KEY }}
          confirm: true

      - uses: https://git.sysctl.io/actions/gotify-action@master
        if: always()
        with:
          gotify_api_base: ${{ secrets.GOTIFY_URL }}
          gotify_app_token: ${{ secrets.GOTIFY_TOKEN }}
          notification_title: |
            [${{ github.repository }}] Deployment ${{ job.status }}
          notification_message: |
            Status: ${{ job.status }}
            Commit: ${{ github.sha }}