diff --git a/.github/actions/clean_up/action.yaml b/.github/actions/clean_up/action.yaml index 1cea3615..6beb772d 100644 --- a/.github/actions/clean_up/action.yaml +++ b/.github/actions/clean_up/action.yaml @@ -41,6 +41,14 @@ outputs: description: "stackit cli version" value: ${{ steps.stackit_version.outputs.version }} + pre_count: + description: "number of resources found" + value: ${{ steps.retrieve_pre.outputs.count }} + + post_count: + description: "number of resources found" + value: ${{ steps.retrieve_post.outputs.count }} + runs: using: "composite" steps: @@ -115,7 +123,8 @@ runs: exit 1 fi - - name: Retrieve resources + - name: Retrieve resources before + id: retrieve_pre run: | echo "::group::retrieve resources" set -e @@ -125,11 +134,15 @@ runs: stackit auth activate-service-account --service-account-key-path .svc_acc.json echo "SQL Server Flex resources:" - stackit --verbosity ${{ inputs.log_level }} --project-id "${{ inputs.project_id }}" beta sqlserverflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}"))' + sql_res=$(stackit --verbosity ${{ inputs.log_level }} --project-id "${{ inputs.project_id }}" beta sqlserverflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}"))') + sql_count=$(echo "$sql_res" | jq -r '.id' | wc -l) echo "PostgreSQL Flex resources:" - stackit --verbosity ${{ inputs.log_level }} --project-id "${{ inputs.project_id }}" postgresflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}"))' + pg_res=$(stackit --verbosity ${{ inputs.log_level }} --project-id "${{ inputs.project_id }}" postgresflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}"))') + pg_count=$(echo "$pg_res" | jq -r '.id' | wc -l) + echo "Number of resources found: ${sql_count} SQL Server Flex, ${pg_count} PostgreSQL Flex" + echo "count=$(( ${pg_count} + ${sql_count} ))" >> $GITHUB_OUTPUT echo "::endgroup::" shell: bash @@ -166,3 +179,26 @@ runs: set -e echo "Skip deleting: list only mode" shell: bash + + - name: Retrieve resources after + id: retrieve_post + run: | + echo "::group::retrieve resources" + set -e + echo "authenticating api" + STACKIT_SERVICE_ACCOUNT_KEY_PATH="${PWD}/.svc_acc.json" + export STACKIT_SERVICE_ACCOUNT_KEY_PATH + stackit auth activate-service-account --service-account-key-path .svc_acc.json + + echo "SQL Server Flex resources:" + sql_res=$(stackit --verbosity ${{ inputs.log_level }} --project-id "${{ inputs.project_id }}" beta sqlserverflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}"))') + sql_count=$(echo "$sql_res" | jq -r '.id' | wc -l) + + echo "PostgreSQL Flex resources:" + pg_res=$(stackit --verbosity ${{ inputs.log_level }} --project-id "${{ inputs.project_id }}" postgresflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}"))') + pg_count=$(echo "$pg_res" | jq -r '.id' | wc -l) + + echo "Number of resources found: ${sql_count} SQL Server Flex, ${pg_count} PostgreSQL Flex" + echo "count=$(( ${pg_count} + ${sql_count} ))" >> $GITHUB_OUTPUT + echo "::endgroup::" + shell: bash diff --git a/.github/workflows/clean_up.yaml b/.github/workflows/clean_up.yaml index d3389ce0..c57d0c1f 100644 --- a/.github/workflows/clean_up.yaml +++ b/.github/workflows/clean_up.yaml @@ -66,7 +66,7 @@ jobs: subtitle: "${{ forgejo.repository }}" event_title: ${{ forgejo.event_name }} event_author: ${{ forgejo.actor }} - event_body: "try to remove all resources with prefix ${{ inputs.res_prefix }}" + event_body: "count before cleaning: ${{ steps.clean.outputs.pre_count }}
count after cleaning: ${{ steps.clean.outputs.post_count }}" event_number: ${{ forgejo.run_number }} event_url: "https://tf-provider.git.onstackit.cloud/stackit-dev-tools/terraform-provider-stackitprivatepreview/actions/runs/${{ forgejo.run_number }}" status: ${{ steps.clean.outcome == 'success' && 'SUCCESS' || 'FAILURE' }}