feat: implement dual CI architecture - comprehensive on fork, lightwe… #2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Deploy All Sites | |
| on: | |
| push: | |
| branches: | |
| - main | |
| workflow_dispatch: | |
| inputs: | |
| force_build_all: | |
| description: 'Force build all sites (portal + all standards)' | |
| required: false | |
| default: 'true' | |
| type: boolean | |
| force_build_portal: | |
| description: 'Force build portal only' | |
| required: false | |
| default: 'false' | |
| type: boolean | |
| force_build_standards: | |
| description: 'Force build specific standards (space-separated: ISBDM LRM fr isbd muldicat unimarc)' | |
| required: false | |
| default: '' | |
| type: string | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: false | |
| jobs: | |
| detect-changes: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| portal: ${{ steps.changes.outputs.portal }} | |
| standards: ${{ steps.changes.outputs.standards }} | |
| standards-list: ${{ steps.list-standards.outputs.standards }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Check for changes | |
| id: changes | |
| run: | | |
| # Check if portal files changed | |
| if git diff --name-only HEAD^ HEAD | grep -qE '^(portal/|packages/theme/)'; then | |
| echo "portal=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "portal=false" >> $GITHUB_OUTPUT | |
| fi | |
| # Check if standards files changed | |
| if git diff --name-only HEAD^ HEAD | grep -qE '^(standards/|packages/theme/)'; then | |
| echo "standards=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "standards=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: List standards to build | |
| id: list-standards | |
| run: | | |
| # Check for manual triggers with force options | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| if [ "${{ github.event.inputs.force_build_all }}" = "true" ]; then | |
| echo "standards=ISBDM LRM fr isbd muldicat unimarc" >> $GITHUB_OUTPUT | |
| elif [ -n "${{ github.event.inputs.force_build_standards }}" ]; then | |
| echo "standards=${{ github.event.inputs.force_build_standards }}" >> $GITHUB_OUTPUT | |
| else | |
| echo "standards=" >> $GITHUB_OUTPUT | |
| fi | |
| elif [ "${{ steps.changes.outputs.standards }}" = "true" ]; then | |
| # Get list of changed standards | |
| changed=$(git diff --name-only HEAD^ HEAD | grep '^standards/' | cut -d'/' -f2 | sort -u | tr '\n' ' ') | |
| if [ -n "$changed" ]; then | |
| echo "standards=$changed" >> $GITHUB_OUTPUT | |
| else | |
| # If only packages/theme changed, build all standards | |
| echo "standards=ISBDM LRM fr isbd muldicat unimarc" >> $GITHUB_OUTPUT | |
| fi | |
| else | |
| echo "standards=" >> $GITHUB_OUTPUT | |
| fi | |
| build-portal: | |
| runs-on: ubuntu-latest | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.portal == 'true' || (github.event_name == 'workflow_dispatch' && (github.event.inputs.force_build_all == 'true' || github.event.inputs.force_build_portal == 'true')) | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'pnpm' | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| run: pnpm install --frozen-lockfile | |
| - name: Build theme package | |
| run: pnpm build:theme | |
| - name: Build portal | |
| run: pnpm exec docusaurus build portal | |
| env: | |
| BASE_URL: /standards-dev/ | |
| NODE_ENV: production | |
| DOCS_ENV: preview | |
| - name: Upload portal artifact | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: portal-build | |
| path: portal/build | |
| retention-days: 1 | |
| build-standards: | |
| runs-on: ubuntu-latest | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.standards == 'true' || (github.event_name == 'workflow_dispatch' && (github.event.inputs.force_build_all == 'true' || github.event.inputs.force_build_standards != '')) | |
| strategy: | |
| matrix: | |
| standard: [ISBDM, LRM, fr, isbd, muldicat, unimarc] | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Check if should build | |
| id: should-build | |
| run: | | |
| standards_list="${{ needs.detect-changes.outputs.standards-list }}" | |
| # Check if this standard should be built | |
| should_build=false | |
| # Manual dispatch with force options | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| if [ "${{ github.event.inputs.force_build_all }}" = "true" ]; then | |
| should_build=true | |
| elif [[ " $standards_list " =~ " ${{ matrix.standard }} " ]]; then | |
| should_build=true | |
| fi | |
| # Normal push with change detection | |
| elif [[ " $standards_list " =~ " ${{ matrix.standard }} " ]]; then | |
| should_build=true | |
| fi | |
| if [ "$should_build" = "true" ]; then | |
| echo "build=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "build=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Setup pnpm | |
| if: steps.should-build.outputs.build == 'true' | |
| uses: pnpm/action-setup@v4 | |
| - name: Setup Node.js | |
| if: steps.should-build.outputs.build == 'true' | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'pnpm' | |
| - name: Get pnpm store directory | |
| if: steps.should-build.outputs.build == 'true' | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| if: steps.should-build.outputs.build == 'true' | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install dependencies | |
| if: steps.should-build.outputs.build == 'true' | |
| run: pnpm install --frozen-lockfile | |
| - name: Build theme package | |
| if: steps.should-build.outputs.build == 'true' | |
| run: pnpm build:theme | |
| - name: Build ${{ matrix.standard }} | |
| if: steps.should-build.outputs.build == 'true' | |
| run: pnpm exec docusaurus build standards/${{ matrix.standard }} | |
| env: | |
| BASE_URL: /standards-dev/${{ matrix.standard }}/ | |
| NODE_ENV: production | |
| DOCS_ENV: preview | |
| - name: Upload ${{ matrix.standard }} artifact | |
| if: steps.should-build.outputs.build == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: ${{ matrix.standard }}-build | |
| path: standards/${{ matrix.standard }}/build | |
| retention-days: 1 | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: [detect-changes, build-portal, build-standards] | |
| if: always() && (needs.build-portal.result == 'success' || needs.build-standards.result == 'success' || needs.build-portal.result == 'skipped' || needs.build-standards.result == 'skipped') | |
| steps: | |
| - name: Create deployment directory | |
| run: mkdir -p deployment | |
| - name: Download portal build | |
| if: needs.build-portal.result == 'success' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: portal-build | |
| path: deployment/ | |
| continue-on-error: true | |
| - name: Download ISBDM build | |
| if: needs.build-standards.result == 'success' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: ISBDM-build | |
| path: deployment/ISBDM | |
| continue-on-error: true | |
| - name: Download LRM build | |
| if: needs.build-standards.result == 'success' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: LRM-build | |
| path: deployment/LRM | |
| continue-on-error: true | |
| - name: Download fr build | |
| if: needs.build-standards.result == 'success' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: fr-build | |
| path: deployment/fr | |
| continue-on-error: true | |
| - name: Download isbd build | |
| if: needs.build-standards.result == 'success' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: isbd-build | |
| path: deployment/isbd | |
| continue-on-error: true | |
| - name: Download muldicat build | |
| if: needs.build-standards.result == 'success' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: muldicat-build | |
| path: deployment/muldicat | |
| continue-on-error: true | |
| - name: Download unimarc build | |
| if: needs.build-standards.result == 'success' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: unimarc-build | |
| path: deployment/unimarc | |
| continue-on-error: true | |
| - name: Create standards index if needed | |
| if: needs.build-standards.result == 'success' | |
| run: | | |
| if [ -d "deployment/ISBDM" ] || [ -d "deployment/LRM" ] || [ -d "deployment/fr" ] || [ -d "deployment/isbd" ] || [ -d "deployment/muldicat" ] || [ -d "deployment/unimarc" ]; then | |
| cat > deployment/standards.html << 'INDEXEOF' | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>IFLA Standards</title> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| <style> | |
| body { | |
| font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; | |
| max-width: 800px; | |
| margin: 0 auto; | |
| padding: 2rem; | |
| background: #f5f5f5; | |
| } | |
| .container { | |
| background: white; | |
| padding: 2rem; | |
| border-radius: 8px; | |
| box-shadow: 0 2px 4px rgba(0,0,0,0.1); | |
| } | |
| h1 { | |
| color: #333; | |
| margin-bottom: 0.5rem; | |
| } | |
| .subtitle { | |
| color: #666; | |
| margin-bottom: 2rem; | |
| } | |
| ul { | |
| list-style: none; | |
| padding: 0; | |
| } | |
| li { | |
| margin: 1rem 0; | |
| } | |
| a { | |
| display: block; | |
| padding: 1rem; | |
| background: #f8f9fa; | |
| color: #0066cc; | |
| text-decoration: none; | |
| border-radius: 4px; | |
| border: 1px solid #e9ecef; | |
| transition: all 0.2s; | |
| } | |
| a:hover { | |
| background: #e9ecef; | |
| border-color: #dee2e6; | |
| transform: translateX(4px); | |
| } | |
| .standard-name { | |
| font-weight: 600; | |
| display: block; | |
| margin-bottom: 0.25rem; | |
| } | |
| .standard-desc { | |
| font-size: 0.875rem; | |
| color: #666; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <div class="container"> | |
| <h1>IFLA Standards Documentation</h1> | |
| <p class="subtitle">International Federation of Library Associations and Institutions</p> | |
| <ul> | |
| <li> | |
| <a href="./ISBDM/"> | |
| <span class="standard-name">ISBDM</span> | |
| <span class="standard-desc">International Standard Bibliographic Description for Manifestations</span> | |
| </a> | |
| </li> | |
| <li> | |
| <a href="./LRM/"> | |
| <span class="standard-name">LRM</span> | |
| <span class="standard-desc">Library Reference Model</span> | |
| </a> | |
| </li> | |
| <li> | |
| <a href="./fr/"> | |
| <span class="standard-name">FR</span> | |
| <span class="standard-desc">Functional Requirements</span> | |
| </a> | |
| </li> | |
| <li> | |
| <a href="./isbd/"> | |
| <span class="standard-name">ISBD</span> | |
| <span class="standard-desc">International Standard Bibliographic Description</span> | |
| </a> | |
| </li> | |
| <li> | |
| <a href="./muldicat/"> | |
| <span class="standard-name">MulDiCat</span> | |
| <span class="standard-desc">Multilingual Dictionary of Cataloguing Terms</span> | |
| </a> | |
| </li> | |
| <li> | |
| <a href="./unimarc/"> | |
| <span class="standard-name">UNIMARC</span> | |
| <span class="standard-desc">Universal Machine-Readable Cataloguing</span> | |
| </a> | |
| </li> | |
| </ul> | |
| </div> | |
| </body> | |
| </html> | |
| INDEXEOF | |
| fi | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload combined artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: deployment | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |