fix: simplify CI to avoid Nx Cloud distributed execution failures #26
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 Dev Environment | |
| on: | |
| push: | |
| branches: | |
| - dev | |
| workflow_dispatch: | |
| inputs: | |
| force_build_all: | |
| description: 'Force build all sites (Portal + all standards)' | |
| required: false | |
| default: 'true' | |
| type: boolean | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages-dev" | |
| 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 }} | |
| packages: ${{ steps.changes.outputs.packages }} | |
| 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/)'; 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/)'; then | |
| echo "standards=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "standards=false" >> $GITHUB_OUTPUT | |
| fi | |
| # Check if packages changed (theme/preset) - triggers rebuild of everything | |
| if git diff --name-only HEAD^ HEAD | grep -qE '^(packages/|pnpm-lock.yaml|package.json|\.github/workflows/)'; then | |
| echo "packages=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "packages=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: List standards to build | |
| id: list-standards | |
| run: | | |
| if [ "${{ steps.changes.outputs.packages }}" = "true" ]; then | |
| # If packages changed, build all standards | |
| echo "standards=ISBDM LRM FRBR isbd muldicat unimarc" >> $GITHUB_OUTPUT | |
| 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' ' ') | |
| echo "standards=$changed" >> $GITHUB_OUTPUT | |
| else | |
| echo "standards=" >> $GITHUB_OUTPUT | |
| fi | |
| build-portal: | |
| runs-on: ubuntu-latest | |
| needs: detect-changes | |
| if: needs.detect-changes.outputs.portal == 'true' || needs.detect-changes.outputs.packages == '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 --no-frozen-lockfile | |
| - name: Build shared-config package | |
| run: npx nx build shared-config | |
| - name: Build theme package | |
| run: pnpm build:theme | |
| - name: Build preset package | |
| run: pnpm build:preset | |
| - name: Build portal | |
| run: pnpm exec docusaurus build portal | |
| env: | |
| BASE_URL: /standards-dev/ | |
| NODE_ENV: production | |
| DOCS_ENV: dev | |
| - 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' || needs.detect-changes.outputs.packages == 'true' | |
| strategy: | |
| matrix: | |
| standard: [ISBDM, LRM, FRBR, isbd, muldicat, unimarc] | |
| steps: | |
| - name: Check if should build | |
| id: should-build | |
| run: | | |
| standards_list="${{ needs.detect-changes.outputs.standards-list }}" | |
| # If packages changed, build all | |
| if [ "${{ needs.detect-changes.outputs.packages }}" = "true" ]; then | |
| echo "build=true" >> $GITHUB_OUTPUT | |
| # If this standard is in the changed list | |
| elif [[ " $standards_list " =~ " ${{ matrix.standard }} " ]]; then | |
| echo "build=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "build=false" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Checkout | |
| if: steps.should-build.outputs.build == 'true' | |
| uses: actions/checkout@v4 | |
| - 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 --no-frozen-lockfile | |
| - name: Build shared-config package | |
| if: steps.should-build.outputs.build == 'true' | |
| run: npx nx build shared-config | |
| - name: Build theme package | |
| if: steps.should-build.outputs.build == 'true' | |
| run: pnpm build:theme | |
| - name: Build preset package | |
| if: steps.should-build.outputs.build == 'true' | |
| run: pnpm build:preset | |
| - 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: dev | |
| - 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 FRBR build | |
| if: needs.build-standards.result == 'success' | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: FRBR-build | |
| path: deployment/FRBR | |
| 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: Check if deployment has content | |
| id: check-content | |
| run: | | |
| if [ -d "deployment" ] && [ "$(ls -A deployment 2>/dev/null)" ]; then | |
| echo "has-content=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "has-content=false" >> $GITHUB_OUTPUT | |
| echo "WARNING: No content to deploy - skipping deployment to prevent wiping existing site" | |
| fi | |
| - name: Create standards index | |
| if: steps.check-content.outputs.has-content == 'true' | |
| run: | | |
| cat > deployment/standards.html << 'INDEXEOF' | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>IFLA Standards - Dev Environment</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; | |
| } | |
| .env-badge { | |
| background: #ff6b35; | |
| color: white; | |
| padding: 0.25rem 0.75rem; | |
| border-radius: 4px; | |
| font-size: 0.8rem; | |
| font-weight: 600; | |
| margin-left: 1rem; | |
| } | |
| 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 <span class="env-badge">DEV</span></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="./FRBR/"> | |
| <span class="standard-name">FRBR</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 | |
| - name: Setup Pages | |
| if: steps.check-content.outputs.has-content == 'true' | |
| uses: actions/configure-pages@v5 | |
| - name: Upload artifact | |
| if: steps.check-content.outputs.has-content == 'true' | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: deployment | |
| - name: Deploy to GitHub Pages | |
| if: steps.check-content.outputs.has-content == 'true' | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |