chore: refactor pipelines (#97)
## Description
<!-- **Please link some issue here describing what you are trying to achieve.**
In case there is no issue present for your PR, please consider creating one.
At least please give us some description what you are trying to achieve and why your change is needed. -->
relates to #1234
## Checklist
- [ ] Issue was linked above
- [ ] Code format was applied: `make fmt`
- [ ] Examples were added / adjusted (see `examples/` directory)
- [x] Docs are up-to-date: `make generate-docs` (will be checked by CI)
- [ ] Unit tests got implemented or updated
- [ ] Acceptance tests got implemented or updated (see e.g. [here](f5f99d1709/stackit/internal/services/dns/dns_acc_test.go))
- [x] Unit tests are passing: `make test` (will be checked by CI)
- [x] No linter issues: `make lint` (will be checked by CI)
Co-authored-by: Marcel S. Henselin <marcel.henselin@stackit.cloud>
Reviewed-on: #97
This commit is contained in:
parent
2893a11c0a
commit
7b2dfaea44
5 changed files with 145 additions and 50 deletions
44
.github/actions/clean_up/action.yaml
vendored
44
.github/actions/clean_up/action.yaml
vendored
|
|
@ -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
|
||||
|
||||
|
|
@ -156,7 +169,7 @@ runs:
|
|||
echo "::group::delete PostgreSQL Flex resources"
|
||||
set -e
|
||||
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; 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" --force; done
|
||||
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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue