You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
2.8 KiB

  1. # This workflow will build and push a node.js application to an Azure Web App when a commit is pushed to your default branch.
  2. #
  3. # This workflow assumes you have already created the target Azure App Service web app.
  4. # For instructions see https://docs.microsoft.com/en-us/azure/app-service/quickstart-nodejs?tabs=linux&pivots=development-environment-cli
  5. #
  6. # To configure this workflow:
  7. #
  8. # 1. Download the Publish Profile for your Azure Web App. You can download this file from the Overview page of your Web App in the Azure Portal.
  9. # For more information: https://docs.microsoft.com/en-us/azure/app-service/deploy-github-actions?tabs=applevel#generate-deployment-credentials
  10. #
  11. # 2. Create a secret in your repository named AZURE_WEBAPP_PUBLISH_PROFILE, paste the publish profile contents as the value of the secret.
  12. # For instructions on obtaining the publish profile see: https://docs.microsoft.com/azure/app-service/deploy-github-actions#configure-the-github-secret
  13. #
  14. # 3. Change the value for the AZURE_WEBAPP_NAME. Optionally, change the AZURE_WEBAPP_PACKAGE_PATH and NODE_VERSION environment variables below.
  15. #
  16. # For more information on GitHub Actions for Azure: https://github.com/Azure/Actions
  17. # For more information on the Azure Web Apps Deploy action: https://github.com/Azure/webapps-deploy
  18. # For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples
  19. on:
  20. push:
  21. branches:
  22. - master
  23. workflow_dispatch:
  24. env:
  25. AZURE_WEBAPP_NAME: your-app-name # set this to your application's name
  26. AZURE_WEBAPP_PACKAGE_PATH: '.' # set this to the path to your web app project, defaults to the repository root
  27. NODE_VERSION: '14.x' # set this to the node version to use
  28. jobs:
  29. build:
  30. runs-on: ubuntu-latest
  31. steps:
  32. - uses: actions/checkout@v2
  33. - name: Set up Node.js
  34. uses: actions/setup-node@v2
  35. with:
  36. node-version: ${{ env.NODE_VERSION }}
  37. cache: 'npm'
  38. - name: npm install, build, and test
  39. run: |
  40. npm install
  41. npm run build --if-present
  42. npm run test --if-present
  43. - name: Upload artifact for deployment job
  44. uses: actions/upload-artifact@v2
  45. with:
  46. name: node-app
  47. path: .
  48. deploy:
  49. runs-on: ubuntu-latest
  50. needs: build
  51. environment:
  52. name: 'Development'
  53. url: ${{ steps.deploy-to-webapp.outputs.webapp-url }}
  54. steps:
  55. - name: Download artifact from build job
  56. uses: actions/download-artifact@v2
  57. with:
  58. name: node-app
  59. - name: 'Deploy to Azure WebApp'
  60. id: deploy-to-webapp
  61. uses: azure/webapps-deploy@v2
  62. with:
  63. app-name: ${{ env.AZURE_WEBAPP_NAME }}
  64. publish-profile: ${{ secrets.AZURE_WEBAPP_PUBLISH_PROFILE }}
  65. package: ${{ env.AZURE_WEBAPP_PACKAGE_PATH }}