forked from oh-sless-t2/ice-cream-infrastructure
-
Notifications
You must be signed in to change notification settings - Fork 2
104 lines (86 loc) · 3.58 KB
/
deployAPIs.yml
File metadata and controls
104 lines (86 loc) · 3.58 KB
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
# This is a basic workflow to help you get started with Actions
name: Deploy APIM Api definitions
on:
workflow_dispatch:
inputs:
environment:
description: "Which env you are updating"
default: "blue"
required: true
type: choice
options:
- original
- blue
- green
env:
DEPNAME: "DepApi${{ github.run_number }}" #Deployment Name
AZCLIVERSION: latest #2.30.0 #Pinning to a specific AZ CLI version
concurrency: github.event.inputs.resourcegroup
jobs:
DeployAPIs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Job parameter check
run: |
echo "environment is: ${{ github.event.inputs.environment }}"
echo "Deployment name is ${{ env.DEPNAME }}"
echo "Ref is ${{ github.ref }}"
echo "EventTrigger name is ${{github.event_name}}"
echo "AZCLIVERSION is ${{ env.AZCLIVERSION }}"
echo "Inputs are ${{ tojson(github.event.inputs) }}"
- name: Set up variables for environment
id: theEnv
run: |
if [ "${{ github.event.inputs.environment }}" == "blue" ]
then
RATINGSAPI='https://app-ratings-vsabv73meajog.azurewebsites.net/api'
RG='team2App-bluedevenv'
APIM='apim-icecreamblue-3plwdf5dpxexw'
fi
if [ "${{ github.event.inputs.environment }}" == "green" ]
then
RATINGSAPI='https://app-ratings-w2y33gzfl7kbo.azurewebsites.net/api'
RG='team2App-greendevenv'
APIM='apim-icecreamgreen-nxwhongiagiiu'
fi
if [ "${{ github.event.inputs.environment }}" == "original" ]
then
RATINGSAPI='https://app-ratings-fi4a3nk4vlrka.azurewebsites.net/api'
RG='team2App-bluedevenv'
APIM='apim-icecreamblue-3plwdf5dpxexw'
fi
echo $RATINGSAPI
echo $RG
echo $APIM
echo "::set-output name=RATINGSAPI::$RATINGSAPI"
echo "::set-output name=RG::$RG"
echo "::set-output name=APIM::$APIM"
- name: Azure Login
uses: Azure/login@v1
with:
creds: ${{ secrets.AZURE_CREDENTIALS }}
enable-AzPSSession: true
environment: azurecloud
allow-no-subscriptions: false
- name: Validate Infrastructure deployment
uses: Azure/cli@1.0.4
with:
azcliversion: ${{ env.AZCLIVERSION }}
inlineScript: |
RG='${{ steps.theEnv.outputs.RG}}'
APIMNAME='${{ steps.theEnv.outputs.APIM}}'
RATINGSURL='${{ steps.theEnv.outputs.RATINGSAPI}}'
az deployment group validate -f apim-apis.bicep -g $RG -p apimName=$APIMNAME ratingsApiBaseUrl="$RATINGSURL"
- name: Deploy Infrastructure
id: deployInfra
uses: Azure/cli@1.0.4
with:
azcliversion: ${{ env.AZCLIVERSION }}
inlineScript: |
RG='${{ steps.theEnv.outputs.RG}}'
APIMNAME='${{ steps.theEnv.outputs.APIM}}'
RATINGSURL='${{ steps.theEnv.outputs.RATINGSAPI}}'
az deployment group create -f apim-apis.bicep -g $RG -p apimName=$APIMNAME ratingsApiBaseUrl="$RATINGSURL" --name $DEPNAME
DEPSTATUS=$(az deployment operation group list --resource-group $RG --name $DEPNAME) #--query "[?properties.provisioningState=='Failed']"
echo $DEPSTATUS