Skip to content

Commit

Permalink
OPSEXP-2689 Add workflow_dispatch option for terraform (#628)
Browse files Browse the repository at this point in the history
  • Loading branch information
pmacius committed May 28, 2024
1 parent 2127d93 commit 7b2b5db
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/terraform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ on:
type: string
required: false
default: .
terraform_operation:
description: the terraform operation to perform (apply or destroy)
type: string
required: false
secrets:
AWS_ACCESS_KEY_ID:
required: false
Expand Down Expand Up @@ -124,9 +128,22 @@ jobs:
- name: Terraform apply
uses: dflook/terraform-apply@8a1bf89017460503cf302632cb15e8583afa7ac4 # v1.42.0
if: github.event_name == 'push'
if: github.event_name == 'push' || inputs.terraform_operation == 'apply'
with:
label: ${{ vars.RESOURCE_NAME }} ${{ inputs.terraform_root_path }}
path: ${{ inputs.terraform_root_path }}
auto_approve: ${{ inputs.terraform_operation == 'apply' }}
var_file: |
${{ inputs.terraform_root_path }}/common.tfvars
${{ inputs.terraform_root_path }}/${{ needs.compute_basic_vars.outputs.environment_name }}.tfvars
backend_config: |
bucket=${{ vars.TERRAFORM_STATE_BUCKET }}
key=${{ vars.RESOURCE_NAME }}/${{ inputs.terraform_root_path }}/terraform.tfstate
- name: Terraform destroy
uses: dflook/terraform-destroy@7f500c95250b8744af0b6c632d54b38d91056062 # v1.42.0
if: inputs.terraform_operation == 'destroy'
with:
path: ${{ inputs.terraform_root_path }}
var_file: |
${{ inputs.terraform_root_path }}/common.tfvars
Expand Down
11 changes: 11 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1562,18 +1562,29 @@ on:
- main
- develop
workflow_dispatch:
inputs:
terraform_operation:
description: 'Perform the requested operation on terraform'
type: choice
required: true
options:
- apply
- destroy
default: apply
jobs:
invoke-terraform-infra:
uses: Alfresco/alfresco-build-tools/.github/workflows/terraform.yml@ref
with:
terraform_root_path: infra
terraform_operation: ${{ inputs.terraform_operation }}
secrets: inherit
invoke-terraform-k8s:
needs: invoke-terraform-infra
uses: Alfresco/alfresco-build-tools/.github/workflows/terraform.yml@ref
with:
terraform_root_path: k8s
terraform_operation: ${{ inputs.terraform_operation }}
secrets: inherit
```

Expand Down
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v5.26.0
v5.27.0

0 comments on commit 7b2b5db

Please sign in to comment.