From db4c51dfc1b1b5f4f9c4cb9291e7b4a166eddf3c Mon Sep 17 00:00:00 2001 From: Tanveer <116706588+Tanveer143s@users.noreply.github.com> Date: Wed, 10 Jul 2024 01:34:17 +0530 Subject: [PATCH] Feat: Updated terraform workflow to stored file to GitHub artifact (#142) Co-authored-by: Vishwajit Nagulkar <119565952+VishwajitNagulkar@users.noreply.github.com> --- .github/workflows/terraform_workflow.yml | 18 ++++++++++++++++++ .github/workflows/tf-checks.yml | 3 +-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/.github/workflows/terraform_workflow.yml b/.github/workflows/terraform_workflow.yml index c8b5ae6..f1d850c 100644 --- a/.github/workflows/terraform_workflow.yml +++ b/.github/workflows/terraform_workflow.yml @@ -238,6 +238,24 @@ jobs: terraform apply -auto-approve fi + - name: Find Errored Terraform State + if: ${{ always() }} + run: | + cd ${{ inputs.working_directory }} + if [ -f "errored.tfstate" ]; then + ls -la errored.tfstate + echo "Uploading errored.tfstate as artifact..." + else + echo "Errored Terraform state file not found." + fi + + - name: Upload Errored Terraform State Artifact + if: ${{ always() }} && success() && steps.find_errored_tfstate.outputs['errored_found'] == 'true' + uses: actions/upload-artifact@v4 + with: + name: errored_tfstate + path: ${{ inputs.working_directory }}/errored.tfstate + - name: Terraform destroy if: ${{ inputs.destroy == true }} id: destroy diff --git a/.github/workflows/tf-checks.yml b/.github/workflows/tf-checks.yml index f5af4e6..c955ea7 100644 --- a/.github/workflows/tf-checks.yml +++ b/.github/workflows/tf-checks.yml @@ -11,9 +11,8 @@ on: type: string default: './examples/complete/' provider: - required: true + required: false type: string - default: gcp description: 'Cloud provider to run the workflow. e.g. azurerm or aws or gcp' terraform_version: description: 'Terraform version to use. Leave empty for the latest version.'