Skip to content

feat: LHCb modules migration #210

feat: LHCb modules migration

feat: LHCb modules migration #210

name: Build & Publish Schemas to Pages
on:
push:
branches: ["main"] # publish "main" to Pages
paths:
- "src/dirac_cwl/metadata/**"
- "src/dirac_cwl/submission_models.py"
- "scripts/generate_schemas.py"
- "pyproject.toml"
pull_request:
branches: ["main"] # PR preview sites
paths:
- "src/dirac_cwl/metadata/**"
- "src/dirac_cwl/submission_models.py"
- "scripts/generate_schemas.py"
- "pyproject.toml"
workflow_dispatch:
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
# Build once and upload the Pages artifact
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Pages
uses: actions/configure-pages@v5
- name: Install Pixi
uses: prefix-dev/setup-pixi@v0.8.1
with:
cache: true
# Build schemas using your Pixi tasks (keeps CI == local)
- name: Build & validate schemas
run: |
pixi run schemas # builds JSON+YAML into generated_schemas/
pixi run validate-schemas # sanity check
shell: pixi run bash -e {0}
# Test that the generated schemas work in practice
- name: Run schema tests
run: |
pixi run test-schemas
shell: pixi run bash -e {0}
# Prepare the static site payload
- name: Prepare site folder
run: |
mkdir -p site/schemas
cp -r generated_schemas/* site/schemas/
# copies used by tests (optional)
mkdir -p site/test-schemas
cp -r test/workflows/test_meta/schemas/* site/test-schemas/ || true
# simple index
cat > site/index.html <<'HTML'
<!doctype html>
<meta charset="utf-8">
<title>dirac_cwl schemas</title>
<h1>dirac_cwl schemas</h1>
<ul>
<li><a href="schemas/">schemas/</a> (from generated_schemas/)</li>
<li><a href="test-schemas/">test-schemas/</a> (copies used in tests)</li>
</ul>
<p>Build: ${GITHUB_SHA}</p>
HTML
# Optional: versioned paths
mkdir -p site/by-branch/${GITHUB_REF_NAME} site/by-sha/${GITHUB_SHA}
cp -r generated_schemas/* site/by-branch/${GITHUB_REF_NAME}/
cp -r generated_schemas/* site/by-sha/${GITHUB_SHA}/
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: site
# Deploy preview for PRs
deploy_preview:
if: github.event_name == 'pull_request'
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.preview_url }} # <-- use preview_url
steps:
- name: Deploy to GitHub Pages (preview)
id: deployment
uses: actions/deploy-pages@v4
with:
preview: true
- name: Post preview link to job summary
env:
PREVIEW_URL: ${{ steps.deployment.outputs.preview_url }}
run: |
echo "# GitHub Pages Preview" >> "$GITHUB_STEP_SUMMARY"
echo "Preview URL: $PREVIEW_URL" >> "$GITHUB_STEP_SUMMARY"
# Deploy production on pushes to main
deploy_prod:
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: build
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }} # production URL
steps:
- name: Deploy to GitHub Pages (production)
id: deployment
uses: actions/deploy-pages@v4