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
|
||||
|
|
|
|||
12
.github/workflows/clean_up.yaml
vendored
12
.github/workflows/clean_up.yaml
vendored
|
|
@ -9,7 +9,13 @@ on:
|
|||
default: true
|
||||
required: true
|
||||
|
||||
logLevel:
|
||||
res_prefix:
|
||||
description: "resource name prefix"
|
||||
type: string
|
||||
default: 'tf-acc-'
|
||||
required: true
|
||||
|
||||
log_level:
|
||||
description: 'Log Level'
|
||||
required: true
|
||||
default: 'warning'
|
||||
|
|
@ -18,6 +24,7 @@ on:
|
|||
- info
|
||||
- warning
|
||||
- debug
|
||||
- error
|
||||
|
||||
jobs:
|
||||
clean:
|
||||
|
|
@ -32,6 +39,7 @@ jobs:
|
|||
with:
|
||||
project_id: ${{ vars.TF_ACC_PROJECT_ID }}
|
||||
region: 'eu01'
|
||||
tf_resource_prefix: 'tf-acc-'
|
||||
tf_resource_prefix: ${{ inputs.res_prefix }}
|
||||
service_account_json_content_b64: "${{ secrets.TF_ACC_SERVICE_ACCOUNT_JSON_B64 }}"
|
||||
list_only: ${{ inputs.list_only }}
|
||||
log_level: ${{ inputs.log_level }}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue