diff --git a/src/commands/vfcli/vfcli-delete-or-release-env.yml b/src/commands/vfcli/vfcli-delete-or-release-env.yml index bd40cd75..960e6214 100644 --- a/src/commands/vfcli/vfcli-delete-or-release-env.yml +++ b/src/commands/vfcli/vfcli-delete-or-release-env.yml @@ -16,6 +16,10 @@ parameters: type: string description: Path to the env_name file default: "/home/circleci/voiceflow/env_name.txt" + reset-db: + type: boolean + description: Whether to reset the database + default: false steps: - restore_cache: key: env_name_cache-{{ .Environment.CIRCLE_PROJECT_REPONAME }}-{{ .Environment.CIRCLE_WORKFLOW_ID }} @@ -36,6 +40,24 @@ steps: if [[ "$env_name" != "null" ]] && [[ -n "$env_name" ]]; then echo "Releasing the environment..... $env_name" vfcli pool release-env --env-name "$env_name" + if [[ << parameters.reset-db >> == true ]]; then + echo "Resetting the database for $env_name" + vfcli pool release-env --env-name "$env_name" + echo "Triggering pipeline with env-name parameter" + response=$(curl -s -o /dev/null -w "%{http_code}" \ + --request POST \ + --url "https://circleci.com/api/v2/project/gh/voiceflow/env-release-system/pipeline" \ + --header "Circle-Token: ${CIRCLECI_API_TOKEN}" \ + --header "content-type: application/json" \ + --data "{\"parameters\":{\"e2e_env_name\":\"$env_name\",\"trigger_pipeline\":true}}") + if [[ $response == "201" ]]; then + echo "Env Release Pipeline triggered successfully. Exiting with success." + exit 0 + else + echo "Failed to trigger pipeline. HTTP status code: $response" + exit 1 + fi + fi vfcli env resume "$env_name" --interactive false vfcli track attach --branch master --components all --name "$env_name" --interactive false --no-circleci vfcli pool free-env --env-name "$env_name" diff --git a/src/commands/vfcli/vfcli-resetdb-free-env.yml b/src/commands/vfcli/vfcli-resetdb-free-env.yml index ab06a29c..e7e551db 100644 --- a/src/commands/vfcli/vfcli-resetdb-free-env.yml +++ b/src/commands/vfcli/vfcli-resetdb-free-env.yml @@ -13,5 +13,4 @@ steps: vfcli env resume "$env_name" --interactive false vfcli track attach --branch master --components all --name "$env_name" --interactive false --no-circleci vfcli env database reset --name "$env_name" - vfcli component restart --name "$env_name" --wait vfcli pool free-env --env-name "$env_name" diff --git a/src/jobs/e2e/release-env.yml b/src/jobs/e2e/release-env.yml index 59e29822..965d3a32 100644 --- a/src/jobs/e2e/release-env.yml +++ b/src/jobs/e2e/release-env.yml @@ -14,9 +14,14 @@ parameters: type: string description: When to run this command default: always + reset-db: + type: boolean + description: Whether to reset the database + default: false steps: - install-vfcli: init-cluster: << parameters.cluster >> - vfcli-delete-or-release-env: env-name: << parameters.env-name >> + reset-db: << parameters.reset-db >> when: << parameters.when >>