-
Notifications
You must be signed in to change notification settings - Fork 1
126 lines (111 loc) · 4.44 KB
/
deploy_all_functions.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# GitHub action that builds and deploys an Azure Function App
# Author: Francisco Leyva
name: Deploy All Functions to Azure
# Controls when the workflow will run
on:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
inputs:
# Update API Manager with the function endpoints (OpenAPI)
update_api:
type: boolean
required: true
default: false
description: Update API Endpoints
env:
DOTNET_VERSION: '8.0.x' # set this to the dotnet version to use
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This job builds and deploy an azure function to Azure
build-and-deploy:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Functions configurations
strategy:
matrix:
include:
- function_name: 'fn-liquid-dev'
package_path: 'LiquidFunctions'
- function_name: 'fn-solid-dev'
package_path: 'SolidFunctions'
- function_name: 'fn-solidus-dev'
package_path: 'SolidusFunctions'
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v4
# Login to Azure using secrets credentials
- name: 'Login via Azure CLI'
uses: Azure/login@v2.1.1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }} # Your Azure credentials
# Setup dotnet command
- name: Setup DotNet ${{ env.DOTNET_VERSION }} Environment
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
# Build Azure Function
- name: 'Run dotnet'
shell: pwsh
run: |
pushd './${{ matrix.package_path }}'
dotnet build --configuration Release --output ./output
popd
# Deploy build to Azure function app environment
- name: 'Run Azure Functions Action'
uses: Azure/functions-action@v1.5.2
with:
app-name: ${{ matrix.function_name }}
package: '${{ matrix.package_path }}/output'
# Azure logout
- name: logout
run: |
az logout
if: always()
# This job updates the Azure (APIM) API with the OpenAPI definition file
# coming from the Azure Function
update-api:
needs: build-and-deploy
if: inputs.update_api
# The type of runner that the job will run on
runs-on: ubuntu-latest
# API Management configuration for each function (optional)
strategy:
matrix:
include:
- azure_api_id: 'liquid-api'
azure_api_path: '/liquid'
azure_api_name: 'Liquid API'
azure_api_spec_url: 'https://fn-liquid-dev.azurewebsites.net/api/openapi/v3.json'
- azure_api_id: 'solid-api'
azure_api_path: '/solid'
azure_api_name: 'Solid API'
azure_api_spec_url: 'https://fn-solid-dev.azurewebsites.net/api/openapi/v3.json'
- azure_api_id: 'solidus-api'
azure_api_path: '/solidus'
azure_api_name: 'Solidus API'
azure_api_spec_url: 'https://fn-solidus-dev.azurewebsites.net/api/openapi/v3.json'
# Azure API Import configuration
env:
AZURE_RG: ${{ secrets.AZURE_RESOURCE_GROUP }} # Resource group name
AZURE_API_SERVICE: ${{ secrets.AZURE_API_MANAGER }} # API Manager ID
AZURE_API_ID: ${{ matrix.azure_api_id }}
AZURE_API_PATH: ${{ matrix.azure_api_path }}
AZURE_API_NAME: ${{ matrix.azure_api_name }}
AZURE_API_SPEC_URL: ${{ matrix.azure_api_spec_url }}
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Login to Azure using secrets credentials
- name: 'Login via Azure CLI'
uses: Azure/login@v2.1.1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
# Run Azure CLI command to import an API definition from an OpenID definition file
- name: Run Azure API Import (CLI)
run: |
az apim api import --path $AZURE_API_PATH --api-id $AZURE_API_ID -g $AZURE_RG -n $AZURE_API_SERVICE --display-name "$AZURE_API_NAME" --specification-url "$AZURE_API_SPEC_URL" --specification-format OpenAPI --protocols https
# Azure logout
- name: logout
run: |
az logout
if: always()