-
Notifications
You must be signed in to change notification settings - Fork 27
/
deploy.sh
executable file
·38 lines (31 loc) · 1.65 KB
/
deploy.sh
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
#!/bin/bash
set -e
which az > /dev/null || { echo "💥 Error! Azure CLI not found, please install https://aka.ms/azure-cli"; exit 1; }
for varName in GITHUB_TOKEN GITHUB_REPO AZURE_REGION AZURE_PREFIX AZURE_RESGRP; do
varVal=$(eval echo "\${$varName}")
[ -z "$varVal" ] && { echo "💥 Error! Required variable '$varName' is unset!"; varUnset=true; }
done
[ $varUnset ] && exit 1
[ "$GITHUB_REPO" == "https://github.com/benc-uk/chatr.git" ] && {
echo "💔 Warning! You should be running from a fork of this repo, not a clone!";
read -n 1 -s -r -p "Press any key to continue, or ctrl+c to exit...";
}
echo -e "\n\n🚀 Deployment started..."
az deployment sub create \
--template-file deploy/main.bicep \
--location "$AZURE_REGION" \
--name chatr \
--parameters githubRepo="$GITHUB_REPO" \
githubToken="$GITHUB_TOKEN" \
resPrefix="$AZURE_PREFIX" \
resGroupName="$AZURE_RESGRP" \
location="$AZURE_REGION"
pubSubConnStr=$(az deployment sub show --name chatr --query 'properties.outputs.pubSubConnStr.value' -o tsv)
storageKey=$(az deployment sub show --name chatr --query 'properties.outputs.storageKey.value' -o tsv)
echo -e "\n🔨 Configuring static web app..."
az staticwebapp appsettings set -n "${AZURE_PREFIX}" --setting-names \
PUBSUB_CONNECTION_STRING="${pubSubConnStr}" \
PUBSUB_HUB="chat" \
STORAGE_ACCOUNT_KEY="${storageKey}" \
STORAGE_ACCOUNT_NAME="${AZURE_PREFIX}store" > /dev/null
echo -e "\n✨ Deployment complete!\n🌐 The URL to accecss the app is: $(az deployment sub show --name chatr --query 'properties.outputs.appUrl.value' -o tsv)"