Skip to content

Commit db4c51d

Browse files
Feat: Updated terraform workflow to stored file to GitHub artifact (#142)
Co-authored-by: Vishwajit Nagulkar <119565952+VishwajitNagulkar@users.noreply.github.com>
1 parent 8dafdc1 commit db4c51d

File tree

2 files changed

+19
-2
lines changed

2 files changed

+19
-2
lines changed

.github/workflows/terraform_workflow.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,24 @@ jobs:
238238
terraform apply -auto-approve
239239
fi
240240
241+
- name: Find Errored Terraform State
242+
if: ${{ always() }}
243+
run: |
244+
cd ${{ inputs.working_directory }}
245+
if [ -f "errored.tfstate" ]; then
246+
ls -la errored.tfstate
247+
echo "Uploading errored.tfstate as artifact..."
248+
else
249+
echo "Errored Terraform state file not found."
250+
fi
251+
252+
- name: Upload Errored Terraform State Artifact
253+
if: ${{ always() }} && success() && steps.find_errored_tfstate.outputs['errored_found'] == 'true'
254+
uses: actions/upload-artifact@v4
255+
with:
256+
name: errored_tfstate
257+
path: ${{ inputs.working_directory }}/errored.tfstate
258+
241259
- name: Terraform destroy
242260
if: ${{ inputs.destroy == true }}
243261
id: destroy

.github/workflows/tf-checks.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ on:
1111
type: string
1212
default: './examples/complete/'
1313
provider:
14-
required: true
14+
required: false
1515
type: string
16-
default: gcp
1716
description: 'Cloud provider to run the workflow. e.g. azurerm or aws or gcp'
1817
terraform_version:
1918
description: 'Terraform version to use. Leave empty for the latest version.'

0 commit comments

Comments
 (0)