refactor updating to new update_tfstate action

use new action in manual e2e test

add token to update tfstate

refactored all e2e tests to use new action
This commit is contained in:
miampf 2024-04-18 16:31:44 +02:00
parent 45fe56d61f
commit 75cb3c20cc
No known key found for this signature in database
GPG Key ID: EF039364B5B6886C
6 changed files with 89 additions and 215 deletions

View File

@ -0,0 +1,64 @@
name: Update TFState
description: "Update the terraform state artifact."
inputs:
name:
description: "The name of the artifact that contains the tfstate."
required: true
runID:
description: "The ID of your current run (github.run_id)."
required: true
encryptionSecret:
description: "The encryption secret for the artifacts."
required: true
runs:
using: "composite"
steps:
- name: Check if tfstate should be deleted
if: always()
shell: bash
run: |
if [ ! -d constellation-terraform ] && [ ! -d constellation-iam-terraform ]; then
echo "DELETE_TF_STATE=true" >> "$GITHUB_ENV"
else
echo "DELETE_TF_STATE=false" >> "$GITHUB_ENV"
fi
- name: Delete tfstate artifact if necessary
if: always() && env.DELETE_TF_STATE == 'true'
uses: ./.github/actions/artifact_delete
with:
name: ${{ inputs.name }}
workflowID: ${{ inputs.runID }}
- name: Prepare terraform state folders
if: always()
shell: bash
run: |
rm -rf to-zip/*
to_upload=""
if [ -d constellation-terraform ]; then
cp -r constellation-terraform to-zip
rm to-zip/constellation-terraform/plan.zip
rm -rf to-zip/constellation-terraform/.terraform
to_upload+="to-zip/constellation-terraform"
fi
if [ -d constellation-iam-terraform ]; then
cp -r constellation-iam-terraform to-zip
rm -rf to-zip/constellation-iam-terraform/.terraform
to_upload+=" to-zip/constellation-iam-terraform"
fi
echo "TO_UPLOAD=$to_upload" >> "$GITHUB_ENV"
- name: Update tfstate
if: always()
uses: ./.github/actions/artifact_upload
with:
name: ${{ inputs.name }}
path: >
${{ env.TO_UPLOAD }}
encryptionSecret: ${{ inputs.encryptionSecret }}
overwrite: true

View File

@ -123,53 +123,15 @@ jobs:
azureCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
gcpServiceAccount: "iam-e2e@constellation-e2e.iam.gserviceaccount.com"
- name: Check if tfstate should be deleted
if: always()
shell: bash
run: |
if [ ! -d constellation-terraform ] && [ ! -d constellation-iam-terraform ]; then
echo "DELETE_TF_STATE=true" >> "$GITHUB_ENV"
else
echo "DELETE_TF_STATE=false" >> "$GITHUB_ENV"
fi
- name: Delete tfstate artifact if necessary
if: always() && env.DELETE_TF_STATE == 'true'
env:
GH_TOKEN: ${{ github.token }}
uses: ./.github/actions/artifact_delete
with:
name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }}
workflowID: ${{ github.run_id }}
- name: Prepare terraform state folders
if: always()
shell: bash
run: |
rm -rf to-zip/*
to_upload=""
if [ -d constellation-terraform ]; then
cp -r constellation-terraform to-zip
rm to-zip/constellation-terraform/plan.zip
rm -rf to-zip/constellation-terraform/.terraform
to_upload+="to-zip/constellation-terraform"
fi
if [ -d constellation-iam-terraform ]; then
cp -r constellation-iam-terraform to-zip
rm -rf to-zip/constellation-iam-terraform/.terraform
to_upload+=" to-zip/constellation-iam-terraform"
fi
echo "TO_UPLOAD=$to_upload" >> "$GITHUB_ENV"
- name: Update tfstate
if: always()
uses: ./.github/actions/artifact_upload
env:
GH_TOKEN: ${{ github.token }}
uses: ./.github/actions/update_tfstate
with:
name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }}
path: >
${{ env.TO_UPLOAD }}
name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }}
runID: ${{ github.run_id }}
encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }}
overwrite: true
- name: Notify about failure
if: |

View File

@ -379,53 +379,15 @@ jobs:
azureCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
gcpServiceAccount: "iam-e2e@constellation-e2e.iam.gserviceaccount.com"
- name: Check if tfstate should be deleted
if: always()
shell: bash
run: |
if [ ! -d constellation-terraform ] && [ ! -d constellation-iam-terraform ]; then
echo "DELETE_TF_STATE=true" >> "$GITHUB_ENV"
else
echo "DELETE_TF_STATE=false" >> "$GITHUB_ENV"
fi
- name: Delete tfstate artifact if necessary
if: always() && env.DELETE_TF_STATE == 'true'
env:
GH_TOKEN: ${{ github.token }}
uses: ./.github/actions/artifact_delete
with:
name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }}
workflowID: ${{ github.run_id }}
- name: Prepare terraform state folders
if: always()
shell: bash
run: |
rm -rf to-zip/*
to_upload=""
if [ -d constellation-terraform ]; then
cp -r constellation-terraform to-zip
rm to-zip/constellation-terraform/plan.zip
rm -rf to-zip/constellation-terraform/.terraform
to_upload+="to-zip/constellation-terraform"
fi
if [ -d constellation-iam-terraform ]; then
cp -r constellation-iam-terraform to-zip
rm -rf to-zip/constellation-iam-terraform/.terraform
to_upload+=" to-zip/constellation-iam-terraform"
fi
echo "TO_UPLOAD=$to_upload" >> "$GITHUB_ENV"
- name: Update tfstate
if: always()
uses: ./.github/actions/artifact_upload
env:
GH_TOKEN: ${{ github.token }}
uses: ./.github/actions/update_tfstate
with:
name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }}
path: >
${{ env.TO_UPLOAD }}
name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }}
runID: ${{ github.run_id }}
encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }}
overwrite: true
e2e-upgrade:
strategy:

View File

@ -379,53 +379,15 @@ jobs:
azureCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
gcpServiceAccount: "iam-e2e@constellation-e2e.iam.gserviceaccount.com"
- name: Check if tfstate should be deleted
if: always()
shell: bash
run: |
if [ ! -d constellation-terraform ] && [ ! -d constellation-iam-terraform ]; then
echo "DELETE_TF_STATE=true" >> "$GITHUB_ENV"
else
echo "DELETE_TF_STATE=false" >> "$GITHUB_ENV"
fi
- name: Delete tfstate artifact if necessary
if: always() && env.DELETE_TF_STATE == 'true'
env:
GH_TOKEN: ${{ github.token }}
uses: ./.github/actions/artifact_delete
with:
name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }}
workflowID: ${{ github.run_id }}
- name: Prepare terraform state folders
if: always()
shell: bash
run: |
rm -rf to-zip/*
to_upload=""
if [ -d constellation-terraform ]; then
cp -r constellation-terraform to-zip
rm to-zip/constellation-terraform/plan.zip
rm -rf to-zip/constellation-terraform/.terraform
to_upload+="to-zip/constellation-terraform"
fi
if [ -d constellation-iam-terraform ]; then
cp -r constellation-iam-terraform to-zip
rm -rf to-zip/constellation-iam-terraform/.terraform
to_upload+=" to-zip/constellation-iam-terraform"
fi
echo "TO_UPLOAD=$to_upload" >> "$GITHUB_ENV"
- name: Update tfstate
if: always()
uses: ./.github/actions/artifact_upload
env:
GH_TOKEN: ${{ github.token }}
uses: ./.github/actions/update_tfstate
with:
name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }}
path: >
${{ env.TO_UPLOAD }}
name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }}
runID: ${{ github.run_id }}
encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }}
overwrite: true
- name: Notify about failure
if: |

View File

@ -280,50 +280,12 @@ jobs:
azureCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
gcpServiceAccount: "iam-e2e@constellation-e2e.iam.gserviceaccount.com"
- name: Check if tfstate should be deleted
if: always()
shell: bash
run: |
if [ ! -d constellation-terraform ] && [ ! -d constellation-iam-terraform ]; then
echo "DELETE_TF_STATE=true" >> "$GITHUB_ENV"
else
echo "DELETE_TF_STATE=false" >> "$GITHUB_ENV"
fi
- name: Delete tfstate artifact if necessary
if: always() && env.DELETE_TF_STATE == 'true'
env:
GH_TOKEN: ${{ github.token }}
uses: ./.github/actions/artifact_delete
with:
name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }}
workflowID: ${{ github.run_id }}
- name: Prepare terraform state folders
if: always()
shell: bash
run: |
rm -rf to-zip/*
to_upload=""
if [ -d constellation-terraform ]; then
cp -r constellation-terraform to-zip
rm to-zip/constellation-terraform/plan.zip
rm -rf to-zip/constellation-terraform/.terraform
to_upload+="to-zip/constellation-terraform"
fi
if [ -d constellation-iam-terraform ]; then
cp -r constellation-iam-terraform to-zip
rm -rf to-zip/constellation-iam-terraform/.terraform
to_upload+=" to-zip/constellation-iam-terraform"
fi
echo "TO_UPLOAD=$to_upload" >> "$GITHUB_ENV"
- name: Update tfstate
if: always()
uses: ./.github/actions/artifact_upload
env:
GH_TOKEN: ${{ github.token }}
uses: ./.github/actions/update_tfstate
with:
name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }}
path: >
${{ env.TO_UPLOAD }}
name: terraform-state-${{ steps.e2e_test.outputs.namePrefix }}
runID: ${{ github.run_id }}
encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }}
overwrite: true

View File

@ -536,53 +536,15 @@ jobs:
azureCredentials: ${{ secrets.AZURE_E2E_IAM_CREDENTIALS }}
gcpServiceAccount: "iam-e2e@constellation-e2e.iam.gserviceaccount.com"
- name: Check if tfstate should be deleted
if: always()
shell: bash
run: |
if [ ! -d constellation-terraform ] && [ ! -d constellation-iam-terraform ]; then
echo "DELETE_TF_STATE=true" >> "$GITHUB_ENV"
else
echo "DELETE_TF_STATE=false" >> "$GITHUB_ENV"
fi
- name: Delete tfstate artifact if necessary
if: always() && env.DELETE_TF_STATE == 'true'
env:
GH_TOKEN: ${{ github.token }}
uses: ./.github/actions/artifact_delete
with:
name: terraform-state-${{ needs.create-cluster.outputs.e2e-name-prefix }}
workflowID: ${{ github.run_id }}
- name: Prepare terraform state folders
if: always()
shell: bash
run: |
rm -rf to-zip/*
to_upload=""
if [ -d constellation-terraform ]; then
cp -r constellation-terraform to-zip
rm to-zip/constellation-terraform/plan.zip
rm -rf to-zip/constellation-terraform/.terraform
to_upload+="to-zip/constellation-terraform"
fi
if [ -d constellation-iam-terraform ]; then
cp -r constellation-iam-terraform to-zip
rm -rf to-zip/constellation-iam-terraform/.terraform
to_upload+=" to-zip/constellation-iam-terraform"
fi
echo "TO_UPLOAD=$to_upload" >> "$GITHUB_ENV"
- name: Update tfstate
if: always()
uses: ./.github/actions/artifact_upload
env:
GH_TOKEN: ${{ github.token }}
uses: ./.github/actions/update_tfstate
with:
name: terraform-state-${{ needs.create-cluster.outputs.e2e-name-prefix }}
path: >
${{ env.TO_UPLOAD }}
name: terraform-state-${{ needs.create-cluster.outputs.e2e-name-prefix }}
runID: ${{ github.run_id }}
encryptionSecret: ${{ secrets.ARTIFACT_ENCRYPT_PASSWD }}
overwrite: true
- name: Notify about failure
if: |