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

feature: add push triggers to cd pipelines #11

Merged
merged 2 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
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
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
Loading