Skip to content

Commit

Permalink
Merge pull request #756 from crowdbotics/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
crowdbotics-apps authored May 23, 2024
2 parents b98de7d + 1c30dba commit 3c69c4b
Show file tree
Hide file tree
Showing 6 changed files with 418 additions and 280 deletions.
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

0 comments on commit 3c69c4b

Please sign in to comment.