fix: update pipelines
[skip ci]
This commit is contained in:
parent
8ab8656b5c
commit
c081f5f7bd
2 changed files with 51 additions and 19 deletions
58
.github/actions/clean_up/action.yaml
vendored
58
.github/actions/clean_up/action.yaml
vendored
|
|
@ -19,23 +19,24 @@ inputs:
|
|||
service_account_json_content:
|
||||
description: "STACKIT service account JSON file contents"
|
||||
required: true
|
||||
default: ""
|
||||
default: ''
|
||||
|
||||
service_account_json_content_b64:
|
||||
description: "STACKIT service account JSON file contents"
|
||||
required: true
|
||||
default: ""
|
||||
default: ''
|
||||
|
||||
list_only:
|
||||
description: "only list resources, DO NOT delete"
|
||||
required: true
|
||||
default: 'true'
|
||||
|
||||
outputs:
|
||||
resources:
|
||||
description: "resource list"
|
||||
value: ${{ steps.resource_lister.outputs.resources }}
|
||||
log_level:
|
||||
description: "Log Level"
|
||||
required: true
|
||||
default: 'warning'
|
||||
|
||||
outputs:
|
||||
cli-version:
|
||||
description: "stackit cli version"
|
||||
value: ${{ steps.stackit_version.outputs.version }}
|
||||
|
|
@ -115,34 +116,57 @@ runs:
|
|||
fi
|
||||
|
||||
- name: Retrieve resources
|
||||
id: resource_lister
|
||||
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
|
||||
RES_JSON=$(stackit --project-id "${{ inputs.project_id }}" beta sqlserverflex instance list --output-format json | jq -r '.[] | select(.name | startswith("${{ inputs.tf_resource_prefix }}"))')
|
||||
echo "resources=$(echo $RES_JSON)" >> $GITHUB_OUTPUT
|
||||
shell: bash
|
||||
|
||||
- name: List resources
|
||||
run: |
|
||||
set -e
|
||||
echo "${{ steps.resource_lister.outputs.resources }}" | jq -r
|
||||
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 }}"))'
|
||||
|
||||
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 }}"))'
|
||||
|
||||
echo "::endgroup::"
|
||||
shell: bash
|
||||
|
||||
- name: Delete SQL Server Flex resources
|
||||
if: ${{ inputs.list_only != 'true' }}
|
||||
run: |
|
||||
echo "::group::delete SQL Server Flex resources"
|
||||
set -e
|
||||
stackit auth activate-service-account --service-account-key-path .svc_acc.json
|
||||
for s in $(stackit --project-id ${{ inputs.project_id }} beta sqlserverflex instance list --output-format json | jq -r '.[] | select(.name | startswith("tf-acc-")) | .id'); do stackit -y --project-id ${{ inputs.project_id }} beta sqlserverflex instance delete $s; done
|
||||
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; done
|
||||
echo "::endgroup::"
|
||||
shell: bash
|
||||
|
||||
- name: Skip Delete SQL Server Flex resources
|
||||
if: ${{ inputs.list_only == 'true' }}
|
||||
run: |
|
||||
echo "::group::delete SQL Server Flex resources"
|
||||
set -e
|
||||
echo "Skip deleting: list only mode"
|
||||
echo "::endgroup::"
|
||||
shell: bash
|
||||
|
||||
- name: Delete PostgreSQL Flex resources
|
||||
if: ${{ inputs.list_only != 'true' }}
|
||||
run: |
|
||||
echo "::group::delete PostgreSQL Flex resources"
|
||||
set -e
|
||||
stackit auth activate-service-account --service-account-key-path .svc_acc.json
|
||||
for s in $(stackit --project-id ${{ inputs.project_id }} postgresflex instance list --output-format json | jq -r '.[] | select(.name | startswith("tf-acc-")) | .id'); do stackit -y --project-id ${{ inputs.project_id }} postgresflex instance delete $s; done
|
||||
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; done
|
||||
echo "::endgroup::"
|
||||
shell: bash
|
||||
|
||||
- name: Skip Delete PostgreSQL Flex resources
|
||||
if: ${{ inputs.list_only == 'true' }}
|
||||
run: |
|
||||
echo "::group::delete PostgreSQL Flex resources"
|
||||
set -e
|
||||
echo "Skip deleting: list only mode"
|
||||
echo "::endgroup::"
|
||||
shell: bash
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue