Build and deploy the function app to Azure #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }} | |