Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: deploy to test and prod environments #173

Merged
merged 1 commit into from
Nov 4, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions terraform/azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
trigger:
# automatically runs on pull requests; this runs the pipeline after merge
# https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/github?view=azure-devops&tabs=yaml#pr-triggers
branches:
include:
- dev
# only run for changes to Terraform files
paths:
include:
Expand All @@ -17,7 +12,12 @@ stages:
# https://learn.microsoft.com/en-us/azure/devops/pipelines/process/expressions?view=azure-devops#conditional-insertion
variables:
# on pull requests, base on target branch; otherwise base on the source branch
workspace: dev
${{ if and(eq(variables['Build.Reason'], 'PullRequest'), in(variables['System.PullRequest.TargetBranch'], 'test', 'prod')) }}:
workspace: "${{variables['System.PullRequest.TargetBranch']}}"
${{ elseif in(variables['Build.SourceBranchName'], 'test', 'prod') }}:
workspace: "${{variables['Build.SourceBranchName']}}"
${{ else }}:
workspace: dev
steps:
# https://github.com/microsoft/azure-pipelines-terraform/tree/main/Tasks/TerraformInstaller#readme
- task: TerraformInstaller@0
Expand Down Expand Up @@ -69,5 +69,5 @@ stages:
workingDirectory: "$(System.DefaultWorkingDirectory)/terraform"
# service connection
environmentServiceNameAzureRM: deployer
# only run on dev
condition: eq(variables['Build.SourceBranchName'], 'dev')
# only run on certain branches
condition: in(variables['Build.SourceBranchName'], 'dev', 'test', 'prod')