Skip to content

Commit b4fef9a

Browse files
committed
Workflow to build and deploy admin app
1 parent 54af077 commit b4fef9a

5 files changed

Lines changed: 140 additions & 2 deletions

File tree

.github/workflows/admin.yaml

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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: 5.0.x
24+
- name: Build
25+
run: dotnet build -c Release
26+
working-directory: ./admin
27+
- name: Publish
28+
run: dotnet publish -c Release
29+
working-directory: ./admin
30+
- name: Zip Functions Package
31+
run: zip -r ../deploy.zip ./
32+
working-directory: ./api/TwoWeeksReady/bin/Release/net5.0/publish/
33+
- name: Upload Deployment Zip
34+
uses: actions/upload-artifact@v2
35+
with:
36+
name: deployment_zip
37+
path: ./api/TwoWeeksReady/bin/Release/netcoreapp3.1/deploy.zip
38+
- name: Upload Deployment Script
39+
uses: actions/upload-artifact@v2
40+
with:
41+
name: deployment_script
42+
path: ./az/deploy-backend.sh
43+
44+
deploy_to_dev:
45+
runs-on: ubuntu-latest
46+
needs: build
47+
# if: github.event_name != 'pull_request'
48+
environment: development
49+
steps:
50+
- name: Download a Deployment Zip
51+
uses: actions/download-artifact@v2
52+
with:
53+
name: deployment_zip
54+
- name: Download a Deployment Script
55+
uses: actions/download-artifact@v2
56+
with:
57+
name: deployment_script
58+
- name: Azure Login
59+
uses: azure/login@v1
60+
with:
61+
creds: ${{ secrets.AZURE_CREDENTIALS }}
62+
- name: Azure Deploy Resources
63+
uses: Azure/[email protected]
64+
with:
65+
inlineScript: |
66+
chmod +x ./deploy-admin-app.sh
67+
./deploy-admin-app.sh -z deploy.zip
68+
69+
deploy_to_beta:
70+
runs-on: ubuntu-latest
71+
needs: deploy_to_dev
72+
# if: github.event_name != 'pull_request'
73+
environment: beta
74+
steps:
75+
- name: Download a Deployment Zip
76+
uses: actions/download-artifact@v2
77+
with:
78+
name: deployment_zip
79+
- name: Download a Deployment Script
80+
uses: actions/download-artifact@v2
81+
with:
82+
name: deployment_script
83+
- name: Azure Login
84+
uses: azure/login@v1
85+
with:
86+
creds: ${{ secrets.AZURE_CREDENTIALS }}
87+
- name: Azure Deploy Resources
88+
uses: Azure/[email protected]
89+
with:
90+
inlineScript: |
91+
chmod +x ./deploy-admin-app.sh
92+
./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)