Skip to content

Commit

Permalink
feature: add push triggers to cd pipelines (#11)
Browse files Browse the repository at this point in the history
<!-- Thank you for submitting a Pull Request. Please fill out the
template below.-->
## Overview/Summary

The PR adds back in push triggers for the CD pipelines and ensures they
don't run during the bootstrapping phase.

## This PR fixes/adds/changes/removes

N/A

### Breaking Changes

N/A

## Testing Evidence

Tested on both environments

## As part of this Pull Request I have

- [x] Checked for duplicate [Pull
Requests](https://github.com/Azure/alz-terraform-accelerator/pulls)
- [x] Associated it with relevant
[issues](https://github.com/Azure/alz-terraform-accelerator/issues), for
tracking and closure.
- [x] Ensured my code/branch is up-to-date with the latest changes in
the `main`
[branch](https://github.com/Azure/alz-terraform-accelerator/tree/main)
- [x] Performed testing and provided evidence.
- [x] Updated relevant and associated documentation.
  • Loading branch information
jaredfholgate authored Sep 24, 2023
1 parent b29d191 commit 914511c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
1 change: 1 addition & 0 deletions bootstrap/modules/github/repository.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ resource "github_repository_file" "alz" {
content = each.value.content
commit_author = "Azure Landing Zone"
commit_email = "[email protected]"
commit_message = "Add ${each.key} [skip ci]"
overwrite_on_create = true
}

Expand Down
12 changes: 7 additions & 5 deletions templates/.ci_cd/.azuredevops/cd.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
---
trigger:
- none
branches:
include:
- main

parameters:
- name: terraform_action
Expand Down Expand Up @@ -46,13 +48,13 @@ stages:
env:
ARM_USE_AZUREAD: true
- task: TerraformTaskV4@4
displayName: Terraform Plan for $${{ parameters.terraform_action }}
displayName: Terraform Plan for $${{ coalesce(parameters.terraform_action, 'Apply') }}
inputs:
provider: 'azurerm'
command: 'plan'
$${{ if eq(parameters.terraform_action, 'apply') }}:
$${{ if eq(coalesce(parameters.terraform_action, 'apply'), 'apply') }}:
commandOptions: '-out=tfplan -input=false'
$${{ if eq(parameters.terraform_action, 'destroy') }}:
$${{ if eq(coalesce(parameters.terraform_action, 'apply'), 'destroy') }}:
commandOptions: "-out=tfplan -input=false -destroy"
environmentServiceNameAzureRM: '${service_connection_name}'
env:
Expand Down Expand Up @@ -115,7 +117,7 @@ stages:
env:
ARM_USE_AZUREAD: true
- task: TerraformTaskV4@4
displayName: Terraform $${{ parameters.terraform_action }}
displayName: Terraform $${{ coalesce(parameters.terraform_action, 'Apply') }}
inputs:
provider: 'azurerm'
command: 'apply'
Expand Down
7 changes: 5 additions & 2 deletions templates/.ci_cd/.github/workflows/cd.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
---
name: Azure Landing Zone Continuous Delivery
on:
push:
branches:
- main
workflow_dispatch:
inputs:
terraform_action:
Expand Down Expand Up @@ -44,7 +47,7 @@ jobs:
-backend-config="container_name=$${{vars.BACKEND_AZURE_STORAGE_ACCOUNT_CONTAINER_NAME}}" \
-backend-config="key=terraform.tfstate"
- name: Terraform Plan for $${{ github.event.inputs.terraform_action }}
- name: Terraform Plan for $${{ github.event.inputs.terraform_action == 'destroy' && 'Destroy' || 'Apply' }}
run: |
# shellcheck disable=SC2086
terraform plan -out=tfplan -input=false $${{ github.event.inputs.terraform_action == 'destroy' && '-destroy' || '' }}
Expand Down Expand Up @@ -96,5 +99,5 @@ jobs:
-backend-config="container_name=$${{vars.BACKEND_AZURE_STORAGE_ACCOUNT_CONTAINER_NAME}}" \
-backend-config="key=terraform.tfstate"
- name: Terraform $${{ github.event.inputs.terraform_action }}
- name: Terraform $${{ github.event.inputs.terraform_action == 'destroy' && 'Destroy' || 'Apply' }}
run: terraform apply -input=false -auto-approve tfplan

0 comments on commit 914511c

Please sign in to comment.