Merge pull request #13 from JustAGhosT/dependabot/npm_and_yarn/deskto… #5
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 Website to Azure | |
| on: | |
| push: | |
| branches: | |
| - master | |
| paths: | |
| - "website/**" | |
| - ".github/workflows/deploy-website.yml" | |
| pull_request: | |
| paths: | |
| - "website/**" | |
| - ".github/workflows/deploy-website.yml" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| env: | |
| AZURE_STATIC_WEB_APPS_API_TOKEN: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | |
| ENVIRONMENT: prod | |
| REGION_ABBR: san | |
| LOCATION: eastus2 | |
| jobs: | |
| build_and_deploy: | |
| name: Build and Deploy Next.js Website | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| lfs: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: website/package-lock.json | |
| - name: Install dependencies | |
| working-directory: website | |
| run: npm ci | |
| - name: Build Next.js app | |
| working-directory: website | |
| run: npm run build | |
| env: | |
| NODE_ENV: production | |
| - name: Deploy to Azure Static Web Apps | |
| uses: Azure/static-web-apps-deploy@v1 | |
| with: | |
| azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} | |
| repo_token: ${{ secrets.GITHUB_TOKEN }} | |
| action: "upload" | |
| app_location: "website/out" | |
| skip_app_build: true | |
| skip_api_build: true | |
| # PR validation - build only, no deploy | |
| validate_pr: | |
| name: Validate Website Build (PR) | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'pull_request' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| lfs: false | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20" | |
| cache: "npm" | |
| cache-dependency-path: website/package-lock.json | |
| - name: Install dependencies | |
| working-directory: website | |
| run: npm ci | |
| - name: Build Next.js app | |
| working-directory: website | |
| run: npm run build | |
| env: | |
| NODE_ENV: production | |
| - name: Validate build output | |
| run: | | |
| echo "✅ Website build successful!" | |
| if [ -d "website/out" ]; then | |
| ls -la website/out/ | |
| if [ -f "website/out/index.html" ] || [ -d "website/out/index" ]; then | |
| echo "✅ Build output validated - index found" | |
| else | |
| echo "::warning::index.html not found but build completed" | |
| fi | |
| else | |
| echo "Note: Output directory 'website/out' not found - Next.js may use different output config" | |
| fi | |
| deploy_infrastructure: | |
| name: Deploy Azure Infrastructure | |
| runs-on: ubuntu-latest | |
| if: github.event_name == 'workflow_dispatch' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Azure Login | |
| uses: azure/login@v2 | |
| with: | |
| creds: ${{ secrets.AZURE_CREDENTIALS }} | |
| - name: Create Resource Group | |
| run: | | |
| az group create \ | |
| --name "${{ env.ENVIRONMENT }}-rg-${{ env.REGION_ABBR }}-codeflow" \ | |
| --location "${{ env.LOCATION }}" \ | |
| --output none | |
| - name: Deploy Bicep Template | |
| run: | | |
| az deployment group create \ | |
| --resource-group "${{ env.ENVIRONMENT }}-rg-${{ env.REGION_ABBR }}-codeflow" \ | |
| --template-file orchestration/infrastructure/bicep/website.bicep \ | |
| --parameters @orchestration/infrastructure/bicep/website-parameters.json \ | |
| --parameters regionAbbr=${{ env.REGION_ABBR }} |