name: Deploy Website to GitHub Pages

# This workflow deploys the website files only.
# Note: The release.yml workflow copies website/* into its deployment
# to ensure apt/yum repos and website files coexist on GitHub Pages.

on:
  push:
    branches: [master]
    paths:
      - 'website/**'
      - '.github/workflows/website.yml'
  workflow_dispatch:

permissions:
  contents: read
  pages: write
  id-token: write

concurrency:
  group: "pages"
  cancel-in-progress: false

jobs:
  deploy:
    name: Deploy to GitHub Pages
    runs-on: ubuntu-latest
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    
    steps:
      - name: Checkout
        uses: actions/checkout@v4
      
      - name: Build site
        run: |
          mkdir -p _site
          # Copy website files as the root
          cp -r website/* _site/
          # Preserve apt/yum repo directories if they exist in current Pages
          # (they'll be rebuilt by release workflow when needed)
      
      - name: Setup Pages
        uses: actions/configure-pages@v4
      
      - name: Upload artifact
        uses: actions/upload-pages-artifact@v3
        with:
          path: './_site'
      
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v4
