Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy QA to Production #759

Merged
merged 10 commits into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/.circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
- run:
name: Generate Pipeline generated_config.yml file
command: |
bash .circleci/generate_gcp_config.sh
bash ".circleci/generate_${BUILD_TYPE}_config.sh"
- continuation/continue:
parameters: '{}'
configuration_path: configs/generated_config.yml
Expand Down
87 changes: 87 additions & 0 deletions {{cookiecutter.project_slug}}/.circleci/generate_azure_config.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/bin/bash
set -o pipefail

BACKEND_PATH=$1

mkdir configs/
cat <<EOF >configs/generated_config.yml
version: 2.1
executors:
python-executor:
docker:
- image: circleci/python:3.9
jobs:
build:
executor: python-executor
steps:
- checkout
- setup_remote_docker:
version: 20.10.7
docker_layer_caching: true
- run:
name: Install Azure CLI
command: |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
- run:
name: Build Docker image
command: docker build -t "$AZURE_REGISTRY_NAME.azurecr.io/$AZURE_APP_NAME:latest" --build-arg SECRET_KEY="build" "."
- run:
name: Login to Azure Container Registry
command: |
az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET --tenant $AZURE_TENANT_ID
az acr login --name $AZURE_REGISTRY_NAME
- run:
name: Push Docker image to ACR
command: docker push "$AZURE_REGISTRY_NAME.azurecr.io/$AZURE_APP_NAME:latest"
- run:
name: Webhook Failed
command: bash "$BACKEND_PATH.circleci/webhook_callback.sh" "failure"
when: on_fail
deploy:
executor: python-executor
steps:
- checkout
- run:
name: Install Azure CLI
command: |
curl -sL https://aka.ms/InstallAzureCLIDeb | sudo bash
- run:
name: Login to Azure
command: |
az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET --tenant $AZURE_TENANT_ID
- run:
name: Set Azure subscription
command: |
az account set --subscription $AZURE_SUBSCRIPTION_ID
- run:
name: Deploy to Azure App Service
command: |
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"
- run:
name: Restart App Service
command: |
az webapp restart --name $AZURE_APP_NAME --resource-group $AZURE_RESOURCE_GROUP_NAME
- run:
name: Webhook Success
command: bash "$BACKEND_PATH.circleci/webhook_callback.sh" "success"
when: on_success
- run:
name: Webhook Failed
command: bash "$BACKEND_PATH.circleci/webhook_callback.sh" "failure"
when: on_fail
workflows:
version: 2
build_and_deploy:
jobs:
- build
- deploy:
requires:
- build
EOF
2 changes: 2 additions & 0 deletions {{cookiecutter.project_slug}}/Pipfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,5 @@ pipenv = "*"
django-import-export = "*"
drf-spectacular = "~=0.26.4"
dj-rest-auth = "==5.0.2"
azure-keyvault-secrets = "~=4.8.0"
azure-identity = "~=1.16.0"
Loading