parameters:
- name: environments
type: object
default:
- name: dev
file: environments/dev/deploy.yaml
dependsOn: Plan
condition: "and(succeeded(), eq(variables['Build.SourceBranch'], 'refs/heads/main'))"
- name: staging
file: environments/staging/deploy.yaml
dependsOn: Deploy_dev
condition: succeeded()
- name: production
file: environments/production/deploy.yaml
dependsOn: Deploy_staging
condition: succeeded()
trigger:
branches:
include:
- main
paths:
include:
- environments/**
# PR triggers work with GitHub/Bitbucket repos.
# For Azure Repos Git, use branch policy build validation instead.
pr:
branches:
include:
- main
paths:
include:
- environments/**
variables:
- group: bluebricks-credentials
- name: BRICKS_NON_INTERACTIVE
value: true
stages:
- stage: Plan
displayName: 'Plan deployments'
jobs:
- job: PlanAll
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: self
- script: |
/bin/bash -c "$(curl -fsSL https://brickscli.s3.eu-west-1.amazonaws.com/releases/latest/install.sh)"
displayName: 'Install bricks CLI'
- ${{ each env in parameters.environments }}:
- script: |
bricks install \
--file ${{ env.file }} \
--plan-only
displayName: 'Plan ${{ env.name }}'
env:
BRICKS_API_KEY: $(BRICKS_API_KEY)
- ${{ each env in parameters.environments }}:
- stage: Deploy_${{ env.name }}
displayName: 'Deploy to ${{ env.name }}'
dependsOn: ${{ env.dependsOn }}
condition: ${{ env.condition }}
jobs:
- deployment: Deploy_${{ env.name }}
pool:
vmImage: 'ubuntu-latest'
environment: bluebricks-${{ env.name }}
strategy:
runOnce:
deploy:
steps:
- checkout: self
- script: |
/bin/bash -c "$(curl -fsSL https://brickscli.s3.eu-west-1.amazonaws.com/releases/latest/install.sh)"
displayName: 'Install bricks CLI'
- script: |
bricks install \
--file ${{ env.file }} \
--yes
displayName: 'Deploy ${{ env.name }}'
env:
BRICKS_API_KEY: $(BRICKS_API_KEY)