-
Notifications
You must be signed in to change notification settings - Fork 65
86 lines (70 loc) · 2.64 KB
/
appservice_create-deployment-slot_README_md.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
on:
schedule:
- cron: '0 9 * * 4'
workflow_dispatch:
name: 'appservice/create-deployment-slot/README.md'
jobs:
validate:
runs-on: 'ubuntu-latest'
steps:
- uses: 'azure/login@v1'
with:
subscription-id: '${{ secrets.AZURE_SUBSCRIPTION_ID }}'
client-id: '${{ secrets.AZURE_CLIENT_ID }}'
tenant-id: '${{ secrets.AZURE_TENANT_ID }}'
- uses: 'actions/checkout@v3'
- run: |
if [[ -z $REGION ]]; then
export REGION=westus
fi
if [[ -z $REGION ]]; then
export REGION=westus
fi
if [[ -z $REGION ]]; then
export REGION=westus
fi
if [[ -z $REGION ]]; then
export REGION=westus
fi
if [[ -z $RESOURCE_GROUP ]]; then
export RESOURCE_GROUP=joazrg-$RANDOM
echo "Using '"$RESOURCE_GROUP"' as resource group"
fi
az group create --name $RESOURCE_GROUP --location $REGION
if [[ -z $APPSERVICE_PLAN ]]; then
export APPSERVICE_PLAN=joazasp-$RANDOM
fi
az appservice plan create \
--resource-group $RESOURCE_GROUP \
--location $REGION \
--name $APPSERVICE_PLAN \
--is-linux \
--sku P1v3
cd appservice/tomcat-helloworld
mvn clean install
export APPSERVICE_TOMCAT_HELLOWORLD=joazasp-tomcat-helloworld-$RANDOM
mvn azure-webapp:deploy \
-DappName=$APPSERVICE_TOMCAT_HELLOWORLD \
-DappServicePlan=$APPSERVICE_PLAN \
-DresourceGroup=$RESOURCE_GROUP
sleep 120
cd ../..
az webapp deployment slot create \
--resource-group $RESOURCE_GROUP \
--name $APPSERVICE_TOMCAT_HELLOWORLD \
--slot staging
az webapp show --name $APPSERVICE_TOMCAT_HELLOWORLD \
--resource-group $RESOURCE_GROUP \
--query=defaultHostName
az webapp deployment slot list --name $APPSERVICE_TOMCAT_HELLOWORLD \
--resource-group $RESOURCE_GROUP \
--query='[0].defaultHostName'
export RESULT=$(az webapp deployment slot list --resource-group $RESOURCE_GROUP --name $APPSERVICE_TOMCAT_HELLOWORLD --output tsv --query '[0].state')
az group delete --name $RESOURCE_GROUP --yes || true
if [[ "$RESULT" != Running ]]; then
echo 'Deployment slot is NOT running'
exit 1
fi
permissions:
contents: 'read'
id-token: 'write'