chore: remove Azure login step from build-deploy workflow and update … #199
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
| # Build and Deploy to Azure Storage Static Website | |
| name: Build and Deploy to Azure Storage | |
| # Controls when the workflow will run | |
| on: | |
| # Triggers the workflow on push events but only for the "main" branch | |
| push: | |
| branches: ["main"] | |
| # Allows you to run this workflow manually from the Actions tab | |
| workflow_dispatch: | |
| env: | |
| PROJECT_NAME: utilplex | |
| AZURE_STORAGE_ACCOUNT: ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }} | |
| jobs: | |
| build: | |
| name: Build Angular Application | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Set up Node 20.x | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "20.x" | |
| cache: 'npm' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build application | |
| run: npm run build:ci | |
| - name: Archive build artifacts | |
| if: success() | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: browser-build | |
| path: dist/utilplex/browser/ | |
| retention-days: 1 | |
| deploy: | |
| name: Deploy to Azure Storage | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - name: Download build artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: browser-build | |
| path: ./browser | |
| - name: Install Azure CLI | |
| run: | | |
| curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash | |
| - name: Enable static website hosting | |
| run: | | |
| az storage blob service-properties update \ | |
| --account-name ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }} \ | |
| --account-key ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }} \ | |
| --static-website \ | |
| --index-document index.html \ | |
| --404-document index.html | |
| - name: Upload files to Azure Storage | |
| run: | | |
| # Upload index.html with short cache (5 minutes) | |
| az storage blob upload-batch \ | |
| --account-name ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }} \ | |
| --account-key ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }} \ | |
| --destination '$web' \ | |
| --source ./browser \ | |
| --pattern "index.html" \ | |
| --content-cache-control "public, max-age=300, must-revalidate" \ | |
| --overwrite | |
| # Upload hashed JS/CSS files with long cache (1 year) | |
| az storage blob upload-batch \ | |
| --account-name ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }} \ | |
| --account-key ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }} \ | |
| --destination '$web' \ | |
| --source ./browser \ | |
| --pattern "*.js" \ | |
| --content-cache-control "public, max-age=31536000, immutable" \ | |
| --overwrite | |
| az storage blob upload-batch \ | |
| --account-name ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }} \ | |
| --account-key ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }} \ | |
| --destination '$web' \ | |
| --source ./browser \ | |
| --pattern "*.css" \ | |
| --content-cache-control "public, max-age=31536000, immutable" \ | |
| --overwrite | |
| # Upload all other files with medium cache (1 day) | |
| az storage blob upload-batch \ | |
| --account-name ${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }} \ | |
| --account-key ${{ secrets.AZURE_STORAGE_ACCOUNT_KEY }} \ | |
| --destination '$web' \ | |
| --source ./browser \ | |
| --content-cache-control "public, max-age=86400" \ | |
| --overwrite | |
| - name: Display deployment URL | |
| run: | | |
| echo "🚀 Deployment successful!" | |
| echo "Static website URL: https://${{ secrets.AZURE_STORAGE_ACCOUNT_NAME }}.z13.web.core.windows.net/" | |
| echo "Note: The exact URL format depends on your Azure region." |