name: Deploy gluecron to itself
# BLOCK W — Self-host. When Gluecron.com receives a push to main, the
# post-receive hook in src/hooks/post-receive.ts forks scripts/self-deploy.sh
# directly. This workflow file remains as an OPTIONAL alternative path for
# operators who prefer the workflow runner over the post-receive hook, or
# as a manual dispatch escape hatch.

on:
  push:
    branches: [main]
  workflow_dispatch: {}

jobs:
  deploy:
    runs-on: self
    steps:
      - name: Run self-deploy.sh inline
        run: |
          if [ ! -x /opt/gluecron/scripts/self-deploy.sh ]; then
            echo "self-deploy.sh missing — run scripts/self-host-bootstrap.ts first"
            exit 1
          fi
          /opt/gluecron/scripts/self-deploy.sh --inline
