name: Sync Domains

on:
  workflow_dispatch: {}
  push:
    branches: [main]
    paths:
      - ops/domains.yaml

jobs:
  sync:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: '3.11'

      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip
          pip install pyyaml requests

      - name: Apply domain configuration
        env:
          GODADDY_API_KEY: ${{ secrets.GODADDY_API_KEY }}
          GODADDY_API_SECRET: ${{ secrets.GODADDY_API_SECRET }}
          CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
          # Optionally set CLOUDFLARE_ACCOUNT_ID if needed by your script
        run: |
          python ops/scripts/apply_domains.py
