# Deploy a static site to giantpanda.site on every push to main (GitHub Actions).
# Source: https://files.giantpanda.site/ci/v1/github-actions.yml — save as .github/workflows/gianthost.yml
#
# 1. Fill in the env values below: they are not secret, so they live in the repository.
# 2. Only the API key is a secret (Settings → Secrets and variables → Actions → New repository secret):
#    GIANTHOST_API_KEY. Make it in Hub → Instellingen → API-sleutels with the purpose "Website publiceren".
# The deploy script is fetched on every run (always the newest v1); see the .sha256 next to it to pin it.
name: Deploy to giantpanda.site

on:
  push:
    branches: [main]

jobs:
  deploy:
    runs-on: ubuntu-latest
    env:
      GIANTHOST_PROFILE_ID: "00000000-0000-0000-0000-000000000000" # company profile of the customer
      GIANTHOST_SITE_ID: "klant-site"                               # the site id: <site id>.sites.giantpanda.site
      GIANTHOST_SOURCE_PATH: ""                                     # folder of the site in this repository; empty = root
      GIANTHOST_BUILD_DIR: "dist"                                   # build output, relative to GIANTHOST_SOURCE_PATH
      GIANTHOST_API_KEY: ${{ secrets.GIANTHOST_API_KEY }}
    defaults:
      run:
        working-directory: ${{ env.GIANTHOST_SOURCE_PATH || '.' }}
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-node@v4
        with:
          node-version: 22
      - run: npm ci
      - run: npm run build
      - run: |
          curl -fsSL https://files.giantpanda.site/ci/v1/deploy-gianthost.mjs -o /tmp/deploy-gianthost.mjs
          node /tmp/deploy-gianthost.mjs "$GIANTHOST_BUILD_DIR"
