-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci-cd): enable automation for multiple environments (#27)
* chore(deps): update terraform providers * fix(terraform): backend type azurerm must be set. -backend-config is for key/val pairs only * docs(terraform): update AAD permissions requirements * feat(pipeline): config depending on branch name aka environment * pipeline: rename comment stage * pipeline: also need to set env for pull requests * pipeline-vars: branch names start with refs/heads * pipeline: more debugging * pipeline: fix typo * pipelines: debug built in variables too * pipeline: try again after re-configuring git branch protection * pipelines: completely refactor since PR target branch var not available for GitHub Repos * stage(detect-draft): remove debugging conditionals * drift: fix pipeline output filename * pipelines: pr-only for PR pipelines * pipeline(ci): ignore docs changes * pipelines: errors if state file locked * docs(pipelines): update
- Loading branch information
Showing
14 changed files
with
239 additions
and
173 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,29 @@ | ||
# Build numbering format | ||
name: $(BuildID) | ||
|
||
trigger: | ||
branches: | ||
include: | ||
- deploy | ||
- main | ||
- production | ||
paths: | ||
exclude: | ||
- '*.md' | ||
- 'backends/*' | ||
- 'images/*' | ||
- '.github/*' | ||
|
||
pr: none | ||
|
||
pool: | ||
vmImage: 'ubuntu-18.04' | ||
|
||
variables: | ||
- group: e2e-gov-demo-kv | ||
- template: vars/global.yaml | ||
- ${{ if eq(variables.isMain, 'True') }}: | ||
- group: e2e-gov-demo-dev-kv | ||
- ${{ if eq(variables.isProduction, 'True') }}: | ||
- group: e2e-gov-demo-kv | ||
|
||
stages: | ||
- stage: ci_stage | ||
displayName: CI Stage | ||
jobs: | ||
- job: ci_job | ||
displayName: Terraform Validate and Lint | ||
steps: | ||
- bash: terraform version | ||
displayName: terraform version | ||
|
||
- bash: terraform init | ||
displayName: terraform init | ||
|
||
- bash: | | ||
terraform validate | ||
terraform fmt -check | ||
displayName: terraform validate and Lint | ||
- stage: cd_stage | ||
displayName: CD Stage | ||
jobs: | ||
- job: deploy | ||
displayName: Terraform Plan and Apply | ||
steps: | ||
- bash: | | ||
terraform init \ | ||
-backend=true \ | ||
-backend-config="storage_account_name=$TF_STATE_BLOB_ACCOUNT_NAME" \ | ||
-backend-config="container_name=$TF_STATE_BLOB_CONTAINER_NAME" \ | ||
-backend-config="key=$TF_STATE_BLOB_FILE" \ | ||
-backend-config="sas_token=$TF_STATE_BLOB_SAS_TOKEN" | ||
displayName: Terraform Init | ||
env: | ||
TF_STATE_BLOB_ACCOUNT_NAME: $(kv-tf-state-blob-account) | ||
TF_STATE_BLOB_CONTAINER_NAME: $(kv-tf-state-blob-container) | ||
TF_STATE_BLOB_FILE: $(kv-tf-state-blob-file) | ||
TF_STATE_BLOB_SAS_TOKEN: $(kv-tf-state-sas-token) | ||
- bash: terraform plan -out=deployment.tfplan -var superadmins_aad_object_id=$AAD_SUPERADMINS_GROUP_ID | ||
displayName: Terraform Plan (ignores drift) | ||
env: | ||
ARM_SUBSCRIPTION_ID: $(kv-arm-subscription-id) | ||
ARM_CLIENT_ID: $(kv-arm-client-id) | ||
ARM_CLIENT_SECRET: $(kv-arm-client-secret) | ||
ARM_TENANT_ID: $(kv-arm-tenant-id) | ||
AZDO_ORG_SERVICE_URL: $(kv-azure-devops-org-url) | ||
AZDO_PERSONAL_ACCESS_TOKEN: $(kv-azure-devops-pat) | ||
AAD_SUPERADMINS_GROUP_ID: $(kv-aad-superadmins-group-id) | ||
|
||
- bash: terraform apply -auto-approve deployment.tfplan | ||
displayName: Terraform Apply | ||
env: | ||
ARM_SUBSCRIPTION_ID: $(kv-arm-subscription-id) | ||
ARM_CLIENT_ID: $(kv-arm-client-id) | ||
ARM_CLIENT_SECRET: $(kv-arm-client-secret) | ||
ARM_TENANT_ID: $(kv-arm-tenant-id) | ||
AZDO_ORG_SERVICE_URL: $(kv-azure-devops-org-url) | ||
AZDO_PERSONAL_ACCESS_TOKEN: $(kv-azure-devops-pat) | ||
- template: templates/ci.yaml | ||
- template: templates/deploy.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
# Build numbering format | ||
name: $(BuildID) | ||
|
||
trigger: | ||
branches: | ||
include: | ||
- main | ||
- dev | ||
- feat/* | ||
- fix/* | ||
|
||
pr: | ||
- main | ||
paths: | ||
exclude: | ||
- '*.md' | ||
- 'backends/*' | ||
- 'images/*' | ||
- '.github/*' | ||
|
||
pool: | ||
vmImage: 'ubuntu-18.04' | ||
|
||
steps: | ||
- bash: terraform init | ||
displayName: init | ||
|
||
- bash: terraform validate | ||
displayName: validate | ||
|
||
- bash: terraform fmt -check | ||
displayName: check format / lint | ||
stages: | ||
- template: stages/ci.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: $(BuildID) | ||
|
||
pool: | ||
vmImage: 'ubuntu-18.04' | ||
|
||
trigger: none # PR only | ||
|
||
pr: | ||
- main | ||
|
||
variables: | ||
- template: vars/global.yaml | ||
- group: e2e-gov-demo-dev-kv # DEV | ||
|
||
stages: | ||
- template: stages/ci.yaml | ||
- template: stages/detect-drift.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
name: $(BuildID) | ||
|
||
pool: | ||
vmImage: 'ubuntu-18.04' | ||
|
||
trigger: none # PR only | ||
|
||
pr: | ||
- production | ||
|
||
variables: | ||
- template: vars/global.yaml | ||
- group: e2e-gov-demo-kv # PROD | ||
|
||
stages: | ||
- template: stages/ci.yaml | ||
- template: stages/detect-drift.yaml |
Oops, something went wrong.