From 774fb3f0604b9121974d73c5c13e2c0898633084 Mon Sep 17 00:00:00 2001 From: miampf Date: Fri, 19 Apr 2024 10:40:06 +0200 Subject: [PATCH] windows integration + work with update_tfstate --- .github/actions/update_tfstate/action.yml | 7 +++++-- .github/workflows/e2e-windows.yml | 23 +++++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/.github/actions/update_tfstate/action.yml b/.github/actions/update_tfstate/action.yml index e135d1cb6..5582ea9e5 100644 --- a/.github/actions/update_tfstate/action.yml +++ b/.github/actions/update_tfstate/action.yml @@ -11,12 +11,15 @@ inputs: encryptionSecret: description: "The encryption secret for the artifacts." required: true + skipDeletion: + description: "Don't try to delete the artifact before updating. You should only use this if you know that no artifact exists." + default: false runs: using: "composite" steps: - name: Check if tfstate should be deleted - if: always() + if: always() && !${{ inputs.skipDeletion }} shell: bash run: | if [ ! -d constellation-terraform ] && [ ! -d constellation-iam-terraform ]; then @@ -26,7 +29,7 @@ runs: fi - name: Delete tfstate artifact if necessary - if: always() && env.DELETE_TF_STATE == 'true' + if: always() && env.DELETE_TF_STATE == 'true' && !${{ inputs.skipDeletion }} uses: ./.github/actions/artifact_delete with: name: ${{ inputs.name }} diff --git a/.github/workflows/e2e-windows.yml b/.github/workflows/e2e-windows.yml index 96906afae..a1df1335a 100644 --- a/.github/workflows/e2e-windows.yml +++ b/.github/workflows/e2e-windows.yml @@ -195,3 +195,26 @@ jobs: test: Windows E2E Test provider: Azure attestationVariant: "azure-sev-snp" + + upload-tfstate: + name: Upload terraform state if it exists + runs-on: ubuntu-22.04 + needs: e2e-test + if: always() + steps: + - name: Checkout + uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 + with: + ref: ${{ !github.event.pull_request.head.repo.fork && github.head_ref || '' }} + + - name: Upload tfstate + if: always() + env: + GH_TOKEN: ${{ github.token }} + uses: ./.github/actions/update_tfstate + with: + name: terraform-state-${{ github.run_id }} + runID: ${{ github.run_id }} + encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }} + skipDeletion: true +