-
Notifications
You must be signed in to change notification settings - Fork 2
74 lines (66 loc) · 2.63 KB
/
release.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
name: Release
env:
# deploymentNameBuild: ${{ github.event.inputs.deploymentNameBuild }}
# location: ${{ github.event.inputs.location }}
resourceGroup: '${{ secrets.PREFIX }}-rg'
releaseAPIMBicepPath: './deploy/release/apim_apis.bicep'
deploymentNameAPIMRelease: '${{ secrets.PREFIX }}apimrelease'
on:
# Only trigger, when the build workflow succeeded and changes were made to the openapi folder
push:
branches:
- main
paths:
- 'deploy/release/openapi/**'
workflow_run:
workflows: ["Build"]
types:
- completed
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# inputs:
# deploymentNameBuild:
# description: 'Deployment Name Build'
# required: true
# location:
# description: 'Location for deployment'
# required: true
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
# LOGIN TO AZURE. THE LOGGED IN SESSION IS ACTIVE TILL A LOGOUT ACTION IS CALLED (OR THE JOB FINISHED)
- uses: azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true
# SET CORRECT AZURE CONTEXT
- name: 'Set context to subscription'
uses: azure/powershell@v1
with:
inlineScript: |
Set-AzContext -Subscription '${{ secrets.AZURE_SUBSCRIPTION_ID }}'
azPSVersion: "latest"
- name: 'Retrieve API Management Instance & Application Insights Name'
uses: azure/powershell@v1
with:
inlineScript: |
$apim = Get-AzApiManagement -ResourceGroupName '${{ env.resourceGroup }}' | Select-Object -Property Name
$appInsights = Get-AzApplicationInsights -ResourceGroupName '${{ env.resourceGroup }}' | Select-Object -Property Name
$apimName = $apim.Name
$appInsightsName = $appInsights.Name
echo "APIM_NAME=$apimName" >> $Env:GITHUB_ENV
echo "APPINSIGHTS_NAME=$appInsightsName" >> $Env:GITHUB_ENV
azPSVersion: "latest"
- name: 'Release API definition to API Management'
uses: azure/powershell@v1
with:
inlineScript: |
New-AzResourceGroupDeployment -Name '${{ env.deploymentNameAPIMRelease }}' -ResourceGroupName '${{ env.resourceGroup }}' -apimName '${{ env.APIM_NAME }}' -appInsightsName '${{ env.APPINSIGHTS_NAME }}' -TemplateFile '${{ env.releaseAPIMBicepPath }}'
azPSVersion: "latest"
# LOGOUT
- name: logout
run: |
az logout