Skip to content

Build and deploy the function app to Azure #7

Build and deploy the function app to Azure

Build and deploy the function app to Azure #7

name: Build and deploy the function app to Azure
on:
workflow_dispatch:
permissions:
id-token: write
contents: read
env:
AZURE_FUNCTIONAPP_NAME: ${{ vars.AZURE_FUNCTIONAPP_NAME }}
WORKING_DIRECTORY: '.'
NODE_VERSION: '20.x'
jobs:
build-and-deploy:
runs-on: ubuntu-latest
defaults:
run:
working-directory: ${{ env.WORKING_DIRECTORY }}
environment: prod
steps:
- name: 'Checkout repo'
uses: actions/checkout@v4
- 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: Setup Node ${{ env.NODE_VERSION }} Environment
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- name: 'Build project'
shell: bash
run: |
npm ci
npm run build
npm run test --if-present
npm prune --omit=dev # Removes packages specified in devDependencies
- name: 'Publish the package to the Azure function app'
uses: Azure/functions-action@v1
id: fa
with:
app-name: ${{ env.AZURE_FUNCTIONAPP_NAME }}
package: ${{ env.WORKING_DIRECTORY }}