@ -152,6 +152,7 @@ jobs:
@@ -152,6 +152,7 @@ jobs:
run : |
echo "Running database migrations..."
for f in `ls -v ./*.sql`; do
echo "Executing file: ${f}..."
sqlcmd -S $MSSQL_HOST -d vault -U $MSSQL_USER -P $MSSQL_PASS -I -i $f
done;
@ -201,6 +202,12 @@ jobs:
@@ -201,6 +202,12 @@ jobs:
echo "::add-mask::$webapp_name"
echo "::set-output name=webapp-name::$webapp_name"
- name : Stop App Service
if : false
env:
AZURE_RESOURCE_GROUP : "bw-qa-env"
run : az webapp stop --name ${{ steps.retrieve-secrets.outputs.webapp-name }} --resource-group $AZURE_RESOURCE_GROUP
- name : Deploy App
uses : azure/webapps-deploy@798e43877120eda6a2a690a4f212c545e586ae31
with:
@ -208,143 +215,8 @@ jobs:
@@ -208,143 +215,8 @@ jobs:
slot-name : "staging"
package : ./${{ matrix.name }}.zip
swap-identity:
runs-on : ubuntu-latest
needs : deploy
steps:
- name : Login to Azure
uses : Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
with:
creds : ${{ secrets.AZURE_QA_KV_CREDENTIALS }}
- name : Retrieve secrets
id : retrieve-secrets
- name : Start App Service
if : false
env:
VAULT_NAME : "bitwarden-qa-kv"
run : |
identity_webapp_name=$(az keyvault secret show --vault-name $VAULT_NAME --name appservices-identity-webapp-name --query value --output tsv)
echo "::add-mask::$identity_webapp_name"
echo "::set-output name=identity-webapp-name::$identity_webapp_name"
- name : Start staging slot
run : az webapp start --name ${{ steps.retrieve-secrets.outputs.identity-webapp-name }} --resource-group bitwarden-qa --slot staging
- name : Make sure staging endpoint is alive
run : |
SUCCESS="no"
while read OUTPUT
do
STATUS=$( curl -is https://${{ steps.retrieve-secrets.outputs.identity-webapp-name }}-staging.azurewebsites.net/.well-known/openid-configuration/jwks | head -1 )
if [[ "$STATUS" == *"200 OK"* ]]; then
echo "It is live!"
SUCCESS="yes"
break
fi
echo -e "STAUS=$STATUS\nRetrying: $OUTPUT"
sleep 4;
done < <(seq 15)
if [[ "$SUCCESS" == "no" ]]; then
exit 1
fi
- name : Swap Identity
run : az webapp deployment slot swap -g bitwarden-qa -n ${{ steps.retrieve-secrets.outputs.identity-webapp-name }} --slot staging --target-slot production
- name : Stop staging slot
run : az webapp stop --name ${{ steps.retrieve-secrets.outputs.identity-webapp-name }} --resource-group bitwarden-qa --slot staging
swap-slots:
runs-on : ubuntu-latest
needs : swap-identity
strategy:
fail-fast : false
matrix:
include:
- name : Api
- name : Billing
- name : Events
- name : Sso
- name : Portal
steps:
- name : Setup
id : setup
run : |
NAME_LOWER=$(echo "${{ matrix.name }}" | awk '{print tolower($0)}')
echo "::set-output name=name_lower::$NAME_LOWER"
- name : Login to Azure
uses : Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
with:
creds : ${{ secrets.AZURE_QA_KV_CREDENTIALS }}
- name : Retrieve secrets
id : retrieve-secrets
env:
VAULT_NAME : "bitwarden-qa-kv"
run : |
webapp_name=$(az keyvault secret show --vault-name $VAULT_NAME --name appservices-${{ steps.setup.outputs.name_lower }}-webapp-name --query value --output tsv)
echo "::add-mask::$webapp_name"
echo "::set-output name=webapp-name::$webapp_name"
- name : Start staging slot
run : az webapp start --name ${{ steps.retrieve-secrets.outputs.webapp-name }} --resource-group bitwarden-qa --slot staging
- name : Make sure staging endpoint is alive
run : |
SUCCESS="no"
while read OUTPUT
do
STATUS=$( curl -is https://${{ steps.retrieve-secrets.outputs.webapp-name }}-staging.azurewebsites.net/alive | head -1 )
if [[ "$STATUS" == *"200 OK"* ]]; then
echo "It is live!"
SUCCESS="yes"
break
fi
echo -e "STAUS=$STATUS\nRetrying: $OUTPUT"
sleep 4;
done < <(seq 15)
if [[ "$SUCCESS" == "no" ]]; then
exit 1
fi
- name : Swap slots
run : az webapp deployment slot swap -g bitwarden-qa -n ${{ steps.retrieve-secrets.outputs.webapp-name }} --slot staging --target-slot production
- name : Stop staging slot
run : az webapp stop --name ${{ steps.retrieve-secrets.outputs.webapp-name }} --resource-group bitwarden-qa --slot staging
swap-admin:
runs-on : ubuntu-latest
needs : swap-slots
steps:
- name : Login to Azure
uses : Azure/login@77f1b2e3fb80c0e8645114159d17008b8a2e475a
with:
creds : ${{ secrets.AZURE_QA_KV_CREDENTIALS }}
- name : Retrieve secrets
id : retrieve-secrets
env:
VAULT_NAME : "bitwarden-qa-kv"
run : |
admin_webapp_name=$(az keyvault secret show --vault-name $VAULT_NAME --name appservices-admin-webapp-name --query value --output tsv)
echo "::add-mask::$admin_webapp_name"
echo "::set-output name=admin-webapp-name::$admin_webapp_name"
- name : Start staging slot
run : az webapp start --name ${{ steps.retrieve-secrets.outputs.admin-webapp-name }} --resource-group bitwarden-qa --slot staging
- name : Make sure staging endpoint is alive
run : |
sleep 60 # I don't think the admin portal has an alive endpoint
- name : Swap Admin
run : az webapp deployment slot swap -g bitwarden-qa -n ${{ steps.retrieve-secrets.outputs.admin-webapp-name }} --slot staging --target-slot production
- name : Stop staging slot
run : az webapp stop --name ${{ steps.retrieve-secrets.outputs.admin-webapp-name }} --resource-group bitwarden-qa --slot staging
AZURE_RESOURCE_GROUP : "bw-qa-env"
run : az webapp start --name ${{ steps.retrieve-secrets.outputs.webapp-name }} --resource-group $AZURE_RESOURCE_GROUP