Skip to content

Commit

Permalink
dtoss-5599 image pipeline database changes template (#91)
Browse files Browse the repository at this point in the history
  • Loading branch information
rfk-nc authored Jan 13, 2025
1 parent 5cc7639 commit 7dd6e83
Show file tree
Hide file tree
Showing 4 changed files with 94 additions and 1 deletion.
1 change: 0 additions & 1 deletion .azuredevops/templates/steps/acr-import-retag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ parameters:
type: string

steps:
- checkout: none
- task: AzureCLI@2
name: publish_images
displayName: Publish $(SELECT_IMAGE_TAG) images to $(ADD_IMAGE_TAG)
Expand Down
19 changes: 19 additions & 0 deletions .azuredevops/templates/steps/apply-database-changes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---

parameters:
- name: serviceConnection
type: string

steps:
- task: AzureCLI@2
name: apply_database_changes
displayName: Apply database changes
inputs:
azureSubscription: ${{ parameters.serviceConnection }}
addSpnToEnvironment: true
failOnStandardError: false
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
# Placeholder for database changes
echo "Applying database changes (placeholder)..."
46 changes: 46 additions & 0 deletions .azuredevops/templates/steps/deploy-images-from-acr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---

parameters:
- name: serviceConnection
type: string

steps:
- task: AzureCLI@2
name: deploy_images
displayName: Deploy images with tag $(ADD_IMAGE_TAG)
inputs:
azureSubscription: ${{ parameters.serviceConnection }}
addSpnToEnvironment: true
failOnStandardError: false
scriptType: bash
scriptLocation: inlineScript
inlineScript: |
# Prerequisite: A DNS A record for the chosen Dev ACR must exist in the Prod privatelink.azurecr.io zone, resolving to the public IP for that ACR
set -eo pipefail
declare -a pids
wait_for_completion() {
# acr tasks are backgrounded for parallelism
local -n arr=$1
for pid in "${arr[@]}"; do
wait ${pid}
done
}
[[ "${DEST_REGISTRY}" =~ dev ]] && az account set -s ${TF_VAR_HUB_SUBSCRIPTION_ID}
repos=$(az acr repository list --name ${DEST_REGISTRY} --output tsv)
for repo in ${repos}; do
functionName=$(echo $repo | sed "s/$(PROJECT_NAME)/$(FUNCTION_NAME_PREFIX)/")
echo "##[debug] Deploying ${repo}:${ADD_IMAGE_TAG} to ${functionName}..."
# Output the command to be run for debugging purposes
echo "##[debug] az functionapp config container set --name $functionName --resource-group $(FUNCTION_RESOURCE_GROUP) --docker-custom-image-name ${DEST_REGISTRY}.azurecr.io/${repo}:${ADD_IMAGE_TAG} --registry-server https://${DEST_REGISTRY}.azurecr.io"
# Uncomment the following line to actually run the command
# az functionapp config container set --name $functionName --resource-group $(FUNCTION_RESOURCE_GROUP) --docker-custom-image-name ${DEST_REGISTRY}.azurecr.io/${repo}:${ADD_IMAGE_TAG} --registry-server https://${DEST_REGISTRY}.azurecr.io &
pids+=($!)
done
wait_for_completion pids
echo "##[debug] All images imported"
29 changes: 29 additions & 0 deletions .azuredevops/templates/steps/run-post-deployment-tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---

parameters:
- name: serviceConnection
type: string

steps:
- task: UseDotNet@2
displayName: 'Use .NET Core sdk and install if required'
inputs:
packageType: 'sdk'
installationPath: $(Agent.ToolsDirectory)/dotnet

# - task: DotNetCoreCLI@2
# displayName: 'Restore dependencies'
# inputs:
# command: 'restore'
# projects: '**/*.csproj'

# - task: DotNetCoreCLI@2
# displayName: 'Build the .NET project'
# inputs:
# command: 'build'
# projects: '**/*.csproj'
# arguments: '--configuration Release'

# - script: |
# dotnet run --project <path-to-your-project-file>
# displayName: 'Run .NET Application'

0 comments on commit 7dd6e83

Please sign in to comment.