Guest User

Untitled

a guest
Oct 15th, 2024
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.48 KB | None | 0 0
  1. name: Deploy Next.js to Azure Web App
  2.  
  3. on:
  4. workflow_dispatch:
  5.  
  6. env:
  7. NODE_VERSION: 20
  8. NEXT_APP_DIR: src/FinPhlo.Web
  9.  
  10. concurrency:
  11. group: ${{ github.workflow }}-${{ github.ref }}
  12. cancel-in-progress: true
  13.  
  14. jobs:
  15. build:
  16. runs-on: ubuntu-latest
  17. defaults:
  18. run:
  19. working-directory: ${{ env.NEXT_APP_DIR }}
  20. steps:
  21. - name: Checkout Repo
  22. uses: actions/checkout@v4
  23.  
  24. - name: Setup Node.js ${{ env.NODE_VERSION }} environment
  25. uses: actions/setup-node@v4
  26. with:
  27. node-version: ${{ env.NODE_VERSION }}
  28. check-latest: true
  29.  
  30. - name: Cache node_modules and .next folder
  31. id: cache
  32. uses: actions/cache@v4
  33. with:
  34. path: |
  35. ~/.npm
  36. ${{ env.NEXT_APP_DIR }}/node_modules
  37. ${{ env.NEXT_APP_DIR }}/.next/cache
  38. 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') }}
  39. restore-keys: |
  40. ${{ runner.os }}-nextjs-${{ hashFiles('${{ env.NEXT_APP_DIR }}/package-lock.json') }}-
  41.  
  42. - name: Install dependencies
  43. if: steps.cache.outputs.cache-hit != 'true'
  44. shell: bash
  45. run: npm install --force
  46.  
  47. - name: Build app
  48. shell: bash
  49. run: npx next build --no-lint
  50.  
  51. - name: Zip artifact for deployment
  52. run: zip ../../web.zip ./* .next -qr
  53.  
  54. - name: Upload artifact
  55. uses: actions/upload-artifact@v3
  56. with:
  57. name: web-app
  58. path: web.zip
  59. retention-days: 30
  60.  
  61. deploy-testing:
  62. environment:
  63. name: Testing
  64. url: ${{ steps.deployment.outputs.webapp-url }}
  65. runs-on: ubuntu-latest
  66. needs: build
  67. permissions:
  68. id-token: write
  69. steps:
  70. - name: Download artifact
  71. uses: actions/download-artifact@v3
  72. with:
  73. name: web-app
  74.  
  75. - name: Azure login
  76. uses: azure/login@v2
  77. with:
  78. client-id: ${{ secrets.AZURE_CLIENT_ID }}
  79. tenant-id: ${{ secrets.AZURE_TENANT_ID }}
  80. subscription-id: ${{ secrets.AZURE_SUBSCRIPTION_ID }}
  81.  
  82. - name: Deploy to Testing
  83. id: deployment
  84. uses: azure/webapps-deploy@v3
  85. with:
  86. app-name: finphlo-testing-frontend-app
  87. package: web.zip
  88. type: zip
Advertisement
Add Comment
Please, Sign In to add comment