Skip to content

Commit

Permalink
Merge pull request #3 from CybercentreCanada/update/push-to-azure
Browse files Browse the repository at this point in the history
Push to the ACR too [dev]
  • Loading branch information
cccs-kevin authored Nov 14, 2022
2 parents 706ef9d + 71aeef2 commit 9c9f9de
Showing 1 changed file with 53 additions and 4 deletions.
57 changes: 53 additions & 4 deletions pipelines/azure-build.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,25 @@
name: build

variables:
- group: unittest-samples
- name: self_location
value: "self_location"
- name: full_self_location
value: "$(Agent.BuildDirectory)/$(self_location)"
- name: samples_location
value: "samples_location"
- name: full_samples_location
value: "$(Agent.BuildDirectory)/$(samples_location)"

resources:
repositories:
- repository: unittest-samples
type: github
name: $(unittest_samples_repository)
ref: main
endpoint: github-repo-sa
trigger: none

trigger:
tags:
include: ["v*"]
Expand All @@ -21,10 +41,39 @@ stages:
inputs:
command: login
containerRegistry: dockerhub
- task: Docker@2
displayName: Login to chimera
inputs:
command: login
containerRegistry: CHIMERA-U-ACR
- checkout: self
fetchDepth: 1
path: $(self_location)
- checkout: unittest-samples
fetchDepth: 1
path: $(samples_location)
- script: |
export TAG=${BUILD_SOURCEBRANCH#"refs/tags/v"}
if [[ "$TAG" == *stable* ]]; then export BUILD_TYPE=stable; else export BUILD_TYPE=latest; fi
docker build --build-arg version=$TAG --build-arg branch=$BUILD_TYPE -t cccs/${BUILD_REPOSITORY_NAME##*/}:$TAG -t cccs/${BUILD_REPOSITORY_NAME##*/}:$BUILD_TYPE -f ./Dockerfile .
workingDirectory: $(full_self_location)
displayName: Build containers
- script: |
[ ! -d "$(pwd)/tests" ] && echo "No tests found" && exit
export TAG=${BUILD_SOURCEBRANCH#"refs/tags/v"}
if [[ "$TAG" == *stable* ]]; then export BUILD_TYPE=stable; else export BUILD_TYPE=latest; fi
[ -f "$(pwd)/tests/requirements.txt" ] && docker run -e FULL_SELF_LOCATION=/opt/al_service -e FULL_SAMPLES_LOCATION=/opt/samples -v /usr/share/ca-certificates/mozilla:/usr/share/ca-certificates/mozilla -v $(pwd)/tests/:/opt/al_service/tests/ -v ${FULL_SAMPLES_LOCATION}:/opt/samples cccs/${BUILD_REPOSITORY_NAME##*/}:$BUILD_TYPE bash -c 'pip install -U -r tests/requirements.txt; pytest -p no:cacheprovider -vv' && exit
docker run -e FULL_SELF_LOCATION=/opt/al_service -e FULL_SAMPLES_LOCATION=/opt/samples -v /usr/share/ca-certificates/mozilla:/usr/share/ca-certificates/mozilla -v $(pwd)/tests/:/opt/al_service/tests/ -v ${FULL_SAMPLES_LOCATION}:/opt/samples cccs/${BUILD_REPOSITORY_NAME##*/}:$BUILD_TYPE bash -c 'pytest -p no:cacheprovider -vv'
workingDirectory: $(full_self_location)
displayName: Test containers
- script: |
set -xv # Echo commands before they are run
export TAG=${BUILD_SOURCEBRANCH#"refs/tags/v"}
if [[ "$TAG" == *stable* ]]; then export BUILD_TYPE=stable; else export BUILD_TYPE=latest; fi
docker build --build-arg version=$TAG --build-arg branch=$BUILD_TYPE -t cccs/assemblyline-service-iparse:$TAG -t cccs/assemblyline-service-iparse:$BUILD_TYPE .
docker push cccs/assemblyline-service-iparse --all-tags
displayName: Deploy to Docker Hub
for IMAGE in "cccs/" "uchimera.azurecr.io/cccs/"
do
docker tag cccs/${BUILD_REPOSITORY_NAME##*/}:$BUILD_TYPE ${IMAGE}${BUILD_REPOSITORY_NAME##*/}:$TAG
docker tag cccs/${BUILD_REPOSITORY_NAME##*/}:$BUILD_TYPE ${IMAGE}${BUILD_REPOSITORY_NAME##*/}:$BUILD_TYPE
docker push ${IMAGE}${BUILD_REPOSITORY_NAME##*/} --all-tags
done
displayName: Deploy to container repositories

0 comments on commit 9c9f9de

Please sign in to comment.