fix: remove localhost from valid environments, replace with local #46
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: 'false' | |
| type: boolean | |
| permissions: | |
| contents: read | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: "pages-dev" | |
| cancel-in-progress: false | |
| jobs: | |
| detect-and-build: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| affected-projects: ${{ steps.affected.outputs.projects }} | |
| has-affected: ${{ steps.affected.outputs.has-affected }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Required for NX affected | |
| - 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: Setup NX Cloud | |
| uses: nrwl/nx-set-shas@v4 | |
| - name: Detect affected projects | |
| id: affected | |
| run: | | |
| if [ "${{ inputs.force_build_all }}" = "true" ]; then | |
| echo "Force building all projects..." | |
| projects=$(nx show projects --type=app | tr '\n' ' ') | |
| echo "projects=$projects" >> $GITHUB_OUTPUT | |
| echo "has-affected=true" >> $GITHUB_OUTPUT | |
| else | |
| echo "Detecting affected projects..." | |
| affected=$(nx show projects --affected --type=app 2>/dev/null | tr '\n' ' ' || echo "") | |
| if [ -z "$affected" ]; then | |
| echo "No affected projects found" | |
| echo "has-affected=false" >> $GITHUB_OUTPUT | |
| else | |
| echo "Affected projects: $affected" | |
| echo "projects=$affected" >> $GITHUB_OUTPUT | |
| echo "has-affected=true" >> $GITHUB_OUTPUT | |
| fi | |
| fi | |
| - name: Build affected projects | |
| if: steps.affected.outputs.has-affected == 'true' | |
| run: | | |
| if [ "${{ inputs.force_build_all }}" = "true" ]; then | |
| nx run-many --target=build --all --parallel=1 --configuration=development | |
| else | |
| nx affected --target=build --parallel=1 --configuration=development | |
| fi | |
| env: | |
| DOCS_ENV: development | |
| NODE_ENV: production | |
| BASE_URL_PREFIX: /standards-dev/ | |
| - name: Upload artifacts for each built project | |
| if: steps.affected.outputs.has-affected == 'true' | |
| run: | | |
| # Upload each built project as a separate artifact | |
| for project in ${{ steps.affected.outputs.projects }}; do | |
| if [ "$project" = "portal" ]; then | |
| project_path="portal" | |
| else | |
| project_path="standards/${project}" | |
| fi | |
| if [ -d "${project_path}/build" ]; then | |
| echo "Uploading artifact for $project..." | |
| # Use actions/upload-artifact@v4 programmatically | |
| mkdir -p /tmp/artifacts | |
| cp -r ${project_path}/build /tmp/artifacts/${project} | |
| fi | |
| done | |
| - name: Upload combined artifact | |
| if: steps.affected.outputs.has-affected == 'true' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: all-builds | |
| path: | | |
| portal/build | |
| standards/*/build | |
| retention-days: 1 | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: detect-and-build | |
| if: needs.detect-and-build.outputs.has-affected == 'true' | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: all-builds | |
| path: . | |
| - name: Combine builds | |
| run: | | |
| mkdir -p combined-build | |
| # Copy portal to root if it exists | |
| if [ -d "portal/build" ]; then | |
| cp -r portal/build/* combined-build/ | |
| mkdir -p combined-build/portal | |
| cp -r portal/build/* combined-build/portal/ | |
| fi | |
| # Copy all standards builds | |
| for standard_dir in standards/*/build; do | |
| if [ -d "$standard_dir" ]; then | |
| standard_name=$(basename $(dirname "$standard_dir")) | |
| mkdir -p combined-build/${standard_name} | |
| cp -r $standard_dir/* combined-build/${standard_name}/ | |
| fi | |
| done | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload to Pages | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| path: combined-build | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |