name: Deploy SkillOS website to GitHub Pages

on:
  push:
    branches: [main]
  workflow_dispatch:

permissions:
  contents: read

concurrency:
  group: skillos-pages-${{ github.ref }}
  cancel-in-progress: true

jobs:
  build:
    name: Verify, build, and package website
    runs-on: ubuntu-latest
    steps:
      - name: Check out repository
        uses: actions/checkout@v6

      - name: Set up Python
        uses: actions/setup-python@v6
        with:
          python-version: '3.13'

      - name: Run SkillOS QA and build GitHub Pages site
        run: python scripts/qa_check.py

      - name: Configure GitHub Pages
        uses: actions/configure-pages@v5

      - name: Upload GitHub Pages artifact
        uses: actions/upload-pages-artifact@v4
        with:
          path: dist
          include-hidden-files: true

  deploy:
    name: Publish to https://montrealai.github.io/skillos/
    needs: build
    runs-on: ubuntu-latest
    permissions:
      contents: read
      pages: write
      id-token: write
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Deploy website
        id: deployment
        uses: actions/deploy-pages@v4
