Skip to content
This repository was archived by the owner on Dec 17, 2025. It is now read-only.

Commit 2653269

Browse files
Cody Redmondsgmagardependabot[bot]crowdbotics-apps
authored
Deploy QA to Production (#759)
* add packages for azure secrets retrieval * add code snippets to get secrets from azure * add script for app startup * add workflow for the azure deployer * call webhook on build fail * do not pin azure package to specific version * add comment for better readability * --- (#755) updated-dependencies: - dependency-name: requests dependency-type: indirect ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: Saurav <sp.gharti@gmail.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Crowdbotics <team@crowdbotics.com>
1 parent 77a8a69 commit 2653269

File tree

6 files changed

+418
-280
lines changed

6 files changed

+418
-280
lines changed

{{cookiecutter.project_slug}}/.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
- run:
1111
name: Generate Pipeline generated_config.yml file
1212
command: |
13-
bash .circleci/generate_gcp_config.sh
13+
bash ".circleci/generate_${BUILD_TYPE}_config.sh"
1414
- continuation/continue:
1515
parameters: '{}'
1616
configuration_path: configs/generated_config.yml
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
#!/bin/bash
2+
set -o pipefail
3+
4+
BACKEND_PATH=$1
5+
6+
mkdir configs/
7+
cat <<EOF >configs/generated_config.yml
8+
version: 2.1
9+
10+
executors:
11+
python-executor:
12+
docker:
13+
- image: circleci/python:3.9
14+
15+
jobs:
16+
build:
17+
executor: python-executor
18+
steps:
19+
- checkout
20+
- setup_remote_docker:
21+
version: 20.10.7
22+
docker_layer_caching: true
23+
- run:
24+
name: Install Azure CLI
25+
command: |
26+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
27+
28+
- run:
29+
name: Build Docker image
30+
command: docker build -t "$AZURE_REGISTRY_NAME.azurecr.io/$AZURE_APP_NAME:latest" --build-arg SECRET_KEY="build" "."
31+
- run:
32+
name: Login to Azure Container Registry
33+
command: |
34+
az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET --tenant $AZURE_TENANT_ID
35+
az acr login --name $AZURE_REGISTRY_NAME
36+
- run:
37+
name: Push Docker image to ACR
38+
command: docker push "$AZURE_REGISTRY_NAME.azurecr.io/$AZURE_APP_NAME:latest"
39+
- run:
40+
name: Webhook Failed
41+
command: bash "$BACKEND_PATH.circleci/webhook_callback.sh" "failure"
42+
when: on_fail
43+
44+
deploy:
45+
executor: python-executor
46+
steps:
47+
- checkout
48+
- run:
49+
name: Install Azure CLI
50+
command: |
51+
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
52+
- run:
53+
name: Login to Azure
54+
command: |
55+
az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET --tenant $AZURE_TENANT_ID
56+
- run:
57+
name: Set Azure subscription
58+
command: |
59+
az account set --subscription $AZURE_SUBSCRIPTION_ID
60+
- run:
61+
name: Deploy to Azure App Service
62+
command: |
63+
az webapp config container set --name $AZURE_APP_NAME --resource-group $AZURE_RESOURCE_GROUP_NAME --container-image-name "$AZURE_REGISTRY_NAME.azurecr.io/$AZURE_APP_NAME:latest" --container-registry-url "https://$AZURE_REGISTRY_NAME.azurecr.io"
64+
- run:
65+
name: Restart App Service
66+
command: |
67+
az webapp restart --name $AZURE_APP_NAME --resource-group $AZURE_RESOURCE_GROUP_NAME
68+
- run:
69+
name: Webhook Success
70+
command: bash "$BACKEND_PATH.circleci/webhook_callback.sh" "success"
71+
when: on_success
72+
73+
- run:
74+
name: Webhook Failed
75+
command: bash "$BACKEND_PATH.circleci/webhook_callback.sh" "failure"
76+
when: on_fail
77+
78+
workflows:
79+
version: 2
80+
build_and_deploy:
81+
jobs:
82+
- build
83+
- deploy:
84+
requires:
85+
- build
86+
87+
EOF

{{cookiecutter.project_slug}}/Pipfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,5 @@ pipenv = "*"
3333
django-import-export = "*"
3434
drf-spectacular = "~=0.26.4"
3535
dj-rest-auth = "==5.0.2"
36+
azure-keyvault-secrets = "~=4.8.0"
37+
azure-identity = "~=1.16.0"

0 commit comments

Comments
 (0)