name: Deploy fil (kreuzberg)

on:
  push:
    branches:
      - main
  workflow_dispatch:

env:
  SERVICE_NAME: fil

jobs:
  deploy:
    runs-on: debian-host

    env:
      PATH: /usr/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/sbin:/bin:/snap/bin

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

      - name: Validate Nomad job
        run: nomad job validate kreuzberg.nomad
        env:
          NOMAD_ADDR: "https://nomad.i80.dk:4646"

      - name: Deploy to Nomad
        run: nomad job run kreuzberg.nomad
        env:
          NOMAD_ADDR: "https://nomad.i80.dk:4646"

      - name: Check deployment status
        run: |
          echo "=== Job status ==="
          nomad job status ${SERVICE_NAME}
          echo "=== Allocations ==="
          nomad job allocs ${SERVICE_NAME}
        env:
          NOMAD_ADDR: "https://nomad.i80.dk:4646"
