name: "Deploy"
on: ["push"]

jobs:
  build:
    runs-on: "docker"

    steps:
      - name: "Checkout"
        uses: "https://code.forgejo.org/actions/checkout@v4"

      - name: "Setup pnpm"
        uses: "https://github.com/pnpm/action-setup@v4"
        with:
          version: 10

      - name: "Setup Node.js"
        uses: "https://code.forgejo.org/actions/setup-node@v4"
        with:
          node-version-file: "package.json"
          cache: "pnpm"

      - name: "Install dependencies"
        run: "pnpm install"

      - name: "Build"
        run: "pnpm build"

      - name: "Upload"
        id: "upload"
        uses: "https://code.forgejo.org/forgejo/upload-artifact@v4"
        with:
          name: "site.zip"
          if-no-files-found: "error"
          path: |
            ./dist/**/*
            !dist/.vite

      - name: "Notify the web server"
        run: >
          curl https://moritzruth.de/_sscdc/notify
          --fail
          -H "Content-Type: application/json"
          -H "Authorization: Bearer ${{ secrets.SSCDC_SECRET }}"
          -d '{ "id": "${{ github.sha }}", "download_url": "https://git.moritzruth.de/${{ github.repository }}/actions/runs/${{ github.run_number }}/artifacts/site.zip" }'