Skip to content

Commit ca160e1

Browse files
authored
Merge pull request #102 from HTBox/admin-app-resources
Workflow to build and deploy admin app
2 parents 54af077 + 7b8da55 commit ca160e1

5 files changed

Lines changed: 144 additions & 2 deletions

File tree

.github/workflows/admin.yaml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
name: Admin App CI/CD
2+
3+
on:
4+
push:
5+
paths:
6+
- 'admin/**'
7+
- '.github/workflows/admin.yaml'
8+
branches: [ master ]
9+
pull_request:
10+
paths:
11+
- 'admin/**'
12+
- '.github/workflows/admin.yaml'
13+
branches: [ master ]
14+
workflow_dispatch:
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- uses: actions/checkout@v2
20+
- name: Setup .NET Core
21+
uses: actions/setup-dotnet@v1
22+
with:
23+
dotnet-version: 3.1.x
24+
- name: Setup .NET 5
25+
uses: actions/setup-dotnet@v1
26+
with:
27+
dotnet-version: 5.0.x
28+
- name: Build
29+
run: dotnet build -c Release
30+
working-directory: ./admin
31+
- name: Publish
32+
run: dotnet publish -c Release
33+
working-directory: ./admin
34+
- name: Zip Functions Package
35+
run: zip -r ../deploy.zip ./
36+
working-directory: ./admin/TwoWeeksReady.Admin/bin/Release/net5.0/publish/
37+
- name: Upload Deployment Zip
38+
uses: actions/upload-artifact@v2
39+
with:
40+
name: deployment_zip
41+
path: ./admin/TwoWeeksReady.Admin/bin/Release/net5.0/deploy.zip
42+
- name: Upload Deployment Script
43+
uses: actions/upload-artifact@v2
44+
with:
45+
name: deployment_script
46+
path: ./az/deploy-admin-app.sh
47+
48+
deploy_to_dev:
49+
runs-on: ubuntu-latest
50+
needs: build
51+
if: github.event_name != 'pull_request'
52+
environment: development
53+
steps:
54+
- name: Download a Deployment Zip
55+
uses: actions/download-artifact@v2
56+
with:
57+
name: deployment_zip
58+
- name: Download a Deployment Script
59+
uses: actions/download-artifact@v2
60+
with:
61+
name: deployment_script
62+
- name: Azure Login
63+
uses: azure/login@v1
64+
with:
65+
creds: ${{ secrets.AZURE_CREDENTIALS }}
66+
- name: Azure Deploy Resources
67+
uses: Azure/[email protected]
68+
with:
69+
inlineScript: |
70+
chmod +x ./deploy-admin-app.sh
71+
./deploy-admin-app.sh -z deploy.zip
72+
73+
deploy_to_beta:
74+
runs-on: ubuntu-latest
75+
needs: deploy_to_dev
76+
if: github.event_name != 'pull_request'
77+
environment: beta
78+
steps:
79+
- name: Download a Deployment Zip
80+
uses: actions/download-artifact@v2
81+
with:
82+
name: deployment_zip
83+
- name: Download a Deployment Script
84+
uses: actions/download-artifact@v2
85+
with:
86+
name: deployment_script
87+
- name: Azure Login
88+
uses: azure/login@v1
89+
with:
90+
creds: ${{ secrets.AZURE_CREDENTIALS }}
91+
- name: Azure Deploy Resources
92+
uses: Azure/[email protected]
93+
with:
94+
inlineScript: |
95+
chmod +x ./deploy-admin-app.sh
96+
./deploy-admin-app.sh -z deploy.zip -r 2wr-beta-resources -e 2wrbeta

admin/TwoWeeksReady.Admin/TwoWeeksReady.Admin.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
<PropertyGroup>
44
<TargetFramework>net5.0</TargetFramework>
5+
<UserSecretsId>4c82d094-3afe-4274-922b-9c0d8bdda7c5</UserSecretsId>
56
</PropertyGroup>
67

78
<ItemGroup>

az/create-admin-app-resources.sh

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/bin/bash
2+
set -e
3+
4+
RESOURCE_GROUP='2wr-resources'
5+
ENV_PREFIX='2wrdev'
6+
LOCATION='centralus'
7+
8+
while getopts :r:e: opt; do
9+
case ${opt} in
10+
r) RESOURCE_GROUP=${OPTARG};;
11+
e) ENV_PREFIX=${OPTARG};;
12+
l) LOCATION=${OPTARG};;
13+
esac
14+
done
15+
16+
az configure -d group=$RESOURCE_GROUP
17+
az configure -d location=$LOCATION
18+
az group create -n $RESOURCE_GROUP
19+
20+
echo "Create Web apps"
21+
APPSERVICEPLAN_NAME=${ENV_PREFIX}admin_asp
22+
WEBAPP_NAME=${ENV_PREFIX}admin
23+
az appservice plan create --sku B1 --name $APPSERVICEPLAN_NAME
24+
az webapp create --plan $APPSERVICEPLAN_NAME --name $WEBAPP_NAME --runtime "DOTNET|5.0"
25+

az/create-backend-resources.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ az functionapp cors add -n $ENV_PREFIX --allowed-origins $ALLOWED_ORIGINS
3737
echo "Create Cosmos DB"
3838
az cosmosdb create -n $ENV_PREFIX --enable-free-tier true
3939
az cosmosdb sql database create -a $ENV_PREFIX -n 2wr --throughput 400
40+
az cosmosdb sql container create -a $ENV_PREFIX -d 2wr -n basekits --partition-key-path "/id"
4041
az cosmosdb sql container create -a $ENV_PREFIX -d 2wr -n familymembers --partition-key-path "/id"
41-
az cosmosdb sql container create -a $ENV_PREFIX -d 2wr -n familyplans --partition-key-path "/id"
42-
az cosmosdb sql container create -a $ENV_PREFIX -d 2wr -n emergencykits --partition-key-path "/id"
42+
az cosmosdb sql container create -a $ENV_PREFIX -d 2wr -n familyplans --partition-key-path "/userid"
43+
az cosmosdb sql container create -a $ENV_PREFIX -d 2wr -n emergencykits --partition-key-path "/userId"
4344
az cosmosdb sql container create -a $ENV_PREFIX -d 2wr -n hazardhunts --partition-key-path "/id"
4445
az cosmosdb sql container create -a $ENV_PREFIX -d 2wr -n hazardinformation --partition-key-path "/id"
4546

az/deploy-admin-app.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/bash
2+
set -e
3+
4+
RESOURCE_GROUP='2wr-resources'
5+
ENV_PREFIX='2wrdev'
6+
7+
while getopts :r:e:z: opt; do
8+
case ${opt} in
9+
r) RESOURCE_GROUP=${OPTARG};;
10+
e) ENV_PREFIX=${OPTARG};;
11+
z) ZIP_PACKAGE=${OPTARG};;
12+
esac
13+
done
14+
15+
az configure -d group=$RESOURCE_GROUP
16+
17+
echo "Deploying admin app"
18+
WEBAPP_NAME=${ENV_PREFIX}admin
19+
az webapp deployment source config-zip -n $WEBAPP_NAME --src $ZIP_PACKAGE

0 commit comments

Comments
 (0)