|
| 1 | +***/ |
| 2 | +# This workflow will build a Node.js project and deploy it to an Azure Functions App on Windows or Linux when a commit is pushed to your default branch. |
| 3 | +# |
| 4 | +# This workflow assumes you have already created the target Azure Functions app. |
| 5 | +# For instructions see: |
| 6 | +# - https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-node |
| 7 | +# - https://learn.microsoft.com/en-us/azure/azure-functions/create-first-function-vs-code-typescript |
| 8 | +# |
| 9 | +# To configure this workflow: |
| 10 | +# 1. Set up the following secrets in your repository: |
| 11 | +# - AZURE_FUNCTIONAPP_PUBLISH_PROFILE |
| 12 | +# 2. Change env variables for your configuration. |
| 13 | +# |
| 14 | +# For more information on: |
| 15 | +# - GitHub Actions for Azure: https://github.com/Azure/Actions |
| 16 | +# - Azure Functions Action: https://github.com/Azure/functions-action |
| 17 | +# - Publish Profile: https://github.com/Azure/functions-action#using-publish-profile-as-deployment-credential-recommended |
| 18 | +# - Azure Service Principal for RBAC: https://github.com/Azure/functions-action#using-azure-service-principal-for-rbac-as-deployment-credential |
| 19 | +# |
| 20 | +# For more samples to get started with GitHub Action workflows to deploy to Azure: https://github.com/Azure/actions-workflow-samples/tree/master/FunctionApp |
| 21 | + |
| 22 | +name: Deploy Node.js project to Azure Function App |
| 23 | + |
| 24 | +on: |
| 25 | + push: |
| 26 | + branches: ["develop"] |
| 27 | + |
| 28 | +env: |
| 29 | + AZURE_FUNCTIONAPP_NAME: 'your-app-name' # set this to your function app name on Azure |
| 30 | + AZURE_FUNCTIONAPP_PACKAGE_PATH: '.' # set this to the path to your function app project, defaults to the repository root |
| 31 | + NODE_VERSION: '16.x' # set this to the node version to use (e.g. '8.x', '10.x', '12.x') |
| 32 | + |
| 33 | +jobs: |
| 34 | + build-and-deploy: |
| 35 | + runs-on: windows-latest # For Linux, use ubuntu-latest |
| 36 | + environment: dev |
| 37 | + steps: |
| 38 | + - name: 'Checkout GitHub Action' |
| 39 | + uses: actions/checkout@v3 |
| 40 | + |
| 41 | + # If you want to use Azure RBAC instead of Publish Profile, then uncomment the task below |
| 42 | + # - name: 'Login via Azure CLI' |
| 43 | + # uses: azure/login@v1 |
| 44 | + # with: |
| 45 | + # creds: ${{ secrets.AZURE_RBAC_CREDENTIALS }} # set up AZURE_RBAC_CREDENTIALS secrets in your repository |
| 46 | + |
| 47 | + - name: Setup Node ${{ env.NODE_VERSION }} Environment |
| 48 | + uses: actions/setup-node@v3 |
| 49 | + with: |
| 50 | + node-version: ${{ env.NODE_VERSION }} |
| 51 | + |
| 52 | + - name: 'Resolve Project Dependencies Using Npm' |
| 53 | + shell: pwsh # For Linux, use bash |
| 54 | + run: | |
| 55 | + pushd './${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}' |
| 56 | + npm install |
| 57 | + npm run build --if-present |
| 58 | + npm run test --if-present |
| 59 | + popd |
| 60 | +
|
| 61 | + - name: 'Run Azure Functions Action' |
| 62 | + uses: Azure/functions-action@v1 |
| 63 | + id: fa |
| 64 | + with: |
| 65 | + app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }} |
| 66 | + package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }} |
| 67 | + publish-profile: ${{ secrets.AZURE_FUNCTIONAPP_PUBLISH_PROFILE }} # Remove publish-profile to use Azure RBAC |
0 commit comments