-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: Saurav <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Crowdbotics <[email protected]>
- Loading branch information
1 parent
77a8a69
commit 2653269
Showing
6 changed files
with
418 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
{{cookiecutter.project_slug}}/.circleci/generate_azure_config.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.