Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- name: Deploy Next.js to Azure Web App
- on:
- workflow_dispatch:
- env:
- NODE_VERSION: 20
- NEXT_APP_DIR: src/FinPhlo.Web
- concurrency:
- group: ${{ github.workflow }}-${{ github.ref }}
- cancel-in-progress: true
- jobs:
- build:
- runs-on: ubuntu-latest
- defaults:
- run:
- working-directory: ${{ env.NEXT_APP_DIR }}
- steps:
- - name: Checkout Repo
- uses: actions/checkout@v4
- - name: Setup Node.js ${{ env.NODE_VERSION }} environment
- uses: actions/setup-node@v4
- with:
- node-version: ${{ env.NODE_VERSION }}
- check-latest: true
- - name: Cache node_modules and .next folder
- id: cache
- uses: actions/cache@v4
- with:
- path: |
- ~/.npm
- ${{ env.NEXT_APP_DIR }}/node_modules
- ${{ env.NEXT_APP_DIR }}/.next/cache
- key: ${{ runner.os }}-nextjs-${{ hashFiles('${{ env.NEXT_APP_DIR }}/package-lock.json') }}-${{ hashFiles('${{ env.NEXT_APP_DIR }}/*.js', '${{ env.NEXT_APP_DIR }}/*.jsx', '${{ env.NEXT_APP_DIR }}/*.ts', '${{ env.NEXT_APP_DIR }}/*.tsx') }}
- restore-keys: |
- ${{ runner.os }}-nextjs-${{ hashFiles('${{ env.NEXT_APP_DIR }}/package-lock.json') }}-
- - name: Install dependencies
- if: steps.cache.outputs.cache-hit != 'true'
- shell: bash
- run: npm install --force
- - name: Build app
- shell: bash
- run: npx next build --no-lint
- - name: Zip artifact for deployment
- run: zip ../../web.zip ./* .next -qr
- - name: Upload artifact
- uses: actions/upload-artifact@v3
- with:
- name: web-app
- path: web.zip
- retention-days: 30
- deploy-testing:
- environment:
- name: Testing
- url: ${{ steps.deployment.outputs.webapp-url }}
- runs-on: ubuntu-latest
- needs: build
- permissions:
- id-token: write
- steps:
- - name: Download artifact
- uses: actions/download-artifact@v3
- with:
- name: web-app
- - name: Azure login
- uses: azure/login@v2
- with:
- client-id: ${{ secrets.AZURE_CLIENT_ID }}
- tenant-id: ${{ secrets.AZURE_TENANT_ID }}
- subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
- - name: Deploy to Testing
- id: deployment
- uses: azure/webapps-deploy@v3
- with:
- app-name: finphlo-testing-frontend-app
- package: web.zip
- type: zip
Advertisement
Add Comment
Please, Sign In to add comment