|
| 1 | +# GitHub action that builds and deploys an Azure Function App |
| 2 | +# Author: Francisco Leyva |
| 3 | +name: Deploy Liquid Functions to Azure |
| 4 | + |
| 5 | +# Controls when the workflow will run |
| 6 | +on: |
| 7 | + # Allows you to run this workflow manually from the Actions tab |
| 8 | + workflow_dispatch: |
| 9 | + inputs: |
| 10 | + # Update API Manager with the function endpoints (OpenAPI) |
| 11 | + update_api: |
| 12 | + type: boolean |
| 13 | + required: true |
| 14 | + default: false |
| 15 | + description: Update API Endpoints |
| 16 | + |
| 17 | +env: |
| 18 | + DOTNET_VERSION: '6.0.x' # set this to the dotnet version to use |
| 19 | + |
| 20 | +# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
| 21 | +jobs: |
| 22 | + # This job builds and deploy an azure function to Azure |
| 23 | + build-and-deploy: |
| 24 | + # The type of runner that the job will run on |
| 25 | + runs-on: ubuntu-latest |
| 26 | + |
| 27 | + # Functions configurations |
| 28 | + strategy: |
| 29 | + matrix: |
| 30 | + include: |
| 31 | + - function_name: 'fn-liquid-dev' |
| 32 | + package_path: 'LiquidFunctions' |
| 33 | + - function_name: 'fn-solid-dev' |
| 34 | + package_path: 'SolidFunctions' |
| 35 | + - function_name: 'fn-solidus-dev' |
| 36 | + package_path: 'SolidusFunctions' |
| 37 | + |
| 38 | + # Steps represent a sequence of tasks that will be executed as part of the job |
| 39 | + steps: |
| 40 | + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
| 41 | + - uses: actions/checkout@v3 |
| 42 | + |
| 43 | + # Login to Azure using secrets credentials |
| 44 | + - name: 'Login via Azure CLI' |
| 45 | + uses: azure/login@v1 |
| 46 | + with: |
| 47 | + creds: ${{ secrets.AZURE_CREDENTIALS }} # Your Azure credentials |
| 48 | + |
| 49 | + # Setup dotnet command |
| 50 | + - name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment |
| 51 | + uses: actions/setup-dotnet@v3 |
| 52 | + with: |
| 53 | + dotnet-version: ${{ env.DOTNET_VERSION }} |
| 54 | + |
| 55 | + # Build Azure Function |
| 56 | + - name: 'Run dotnet' |
| 57 | + shell: pwsh |
| 58 | + run: | |
| 59 | + pushd './${{ matrix.package_path }}' |
| 60 | + dotnet build --configuration Release --output ./output |
| 61 | + popd |
| 62 | + # Deploy build to Azure function app environment |
| 63 | + - name: 'Run Azure Functions Action' |
| 64 | + uses: Azure/functions-action@v1 |
| 65 | + with: |
| 66 | + app-name: ${{ matrix.function_name }} |
| 67 | + package: '${{ matrix.package_path }}/output' |
| 68 | + |
| 69 | + # Azure logout |
| 70 | + - name: logout |
| 71 | + run: | |
| 72 | + az logout |
| 73 | + if: always() |
0 commit comments