diff --git a/.github/actions/clean_up/action.yaml b/.github/actions/clean_up/action.yaml index 8c28cd27..2fb12e2c 100644 --- a/.github/actions/clean_up/action.yaml +++ b/.github/actions/clean_up/action.yaml @@ -49,6 +49,10 @@ outputs: description: "number of resources found" value: ${{ steps.retrieve_post.outputs.count }} + status: + description: "status of the test" + value: ${{ steps.status.outputs.status }} + runs: using: "composite" steps: @@ -148,12 +152,13 @@ runs: - name: Delete SQL Server Flex resources if: ${{ inputs.list_only != 'true' }} + id: del_sql run: | echo "::group::delete SQL Server Flex resources" stackit --verbosity ${{ inputs.log_level }} auth activate-service-account --service-account-key-path .svc_acc.json for s in $(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 }}")) | .id'); do - stackit --verbosity ${{ inputs.log_level }} -y --project-id ${{ inputs.project_id }} beta sqlserverflex instance delete $s || continue; + stackit --verbosity ${{ inputs.log_level }} -y --project-id ${{ inputs.project_id }} beta sqlserverflex instance delete $s || (echo "status=FAILURE" >> ${GITHUB_OUTPUT} && continue); done echo "::endgroup::" shell: bash @@ -167,12 +172,13 @@ runs: - name: Delete PostgreSQL Flex resources if: ${{ inputs.list_only != 'true' }} + id: del_pg run: | echo "::group::delete PostgreSQL Flex resources" stackit auth activate-service-account --service-account-key-path .svc_acc.json for s in $(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 }}")) | .id'); do - stackit --verbosity ${{ inputs.log_level }} -y --project-id ${{ inputs.project_id }} postgresflex instance delete "$s" --force || continue; + stackit --verbosity ${{ inputs.log_level }} -y --project-id ${{ inputs.project_id }} postgresflex instance delete "$s" --force || (echo "status=FAILURE" >> ${GITHUB_OUTPUT} && continue); done echo "::endgroup::" shell: bash @@ -206,3 +212,20 @@ runs: echo "count=$(( ${pg_count} + ${sql_count} ))" >> $GITHUB_OUTPUT echo "::endgroup::" shell: bash + + - name: Set status + if: always() + id: status + run: | + if [[ ${{ inputs.list_only }} ]]; then + echo "status=SUCCESS" >> $GITHUB_OUTPUT + else + if [[ "${{ steps.del_pg.outputs.status }}" == "FAILURE" ]]; then + echo "status=FAILURE" >> $GITHUB_OUTPUT + elif [[ "${{ steps.del_sql.outputs.status }}" == "FAILURE" ]]; then + echo "status=FAILURE" >> $GITHUB_OUTPUT + else + echo "status=SUCCESS" >> $GITHUB_OUTPUT + fi + fi + shell: bash