Add a deployment stage that has the build dependencies, from a job or more then a job, and thus downloads the artifacts of those jobs see below .gitlab-ci.yml:
stages:
- build
- ...
- deploy
buildjob:1:
stage: build
script:
- build_to_web_dir.sh
artifacts:
paths:
- web
buildjob:2:
stage: build
script:
- build_to_web_dir.sh
artifacts:
paths:
- web
deploy:
stage: deploy
GIT_STRATEGY: none
image: microsoft/azure-cli
dependencies:
- buildjob:1
- buildjob:2
script:
- export containerName=mynewcontainername
- export storageAccount=mystorageaccount
- az storage blob delete-batch --source ${containerName} --account-name ${storageAccount} --output table
- az storage blob upload-batch --source ./web --destination ${containerName} --account-name ${storageAccount} --output table --no-progress
In the deploy job, only one directory will be in the CI_PROJECT_DIR ./web
containing all files that the build jobs have produced.
checkout storage quickstart azure for creating and setting up the storage container, account details etc.
For the deploy stage we can use the microsoft/azure-cli
docker image, so we can call from our script the az
command, see storage-quickstart-blobs-cli for more detail explanation.
az storage blob upload-batch --source ./web --destination ${containerName} --account-name ${storageAccount} --output blobname --no-progress
will copy ./web to the storage container
we should not export for security reasons in the .gitlab-ci.yml
:
export AZURE_STORAGE_ACCOUNT="mystorageaccountname"
export AZURE_STORAGE_ACCESS_KEY="myStorageAccountKey"
but they should be defined in the project_or_group/settings/ci_cd environment variables, so they'll be present in the script environment.