diff --git a/action.yaml b/action.yaml index b4afc46..59901eb 100644 --- a/action.yaml +++ b/action.yaml @@ -93,20 +93,24 @@ runs: - name: Define Domains id: stackspot-url run: | - if [ "${{ inputs.BETA_CLI_ENVIRONMENT }}" == "stg" ]; then + if [ "${{ inputs.BETA_ENVIRONMENT }}" == "stg" ]; then STACKSPOT_IAM_URL="https://iam-auth-ssr.stg.stackspot.com" STACKSPOT_RUNTIME_MANAGER_URL="https://runtime-manager.stg.stackspot.com" + STACKSPOT_WORKSPACE_URL="https://workspace-workspace-api.stg.stackspot.com" - elif [ "${{ inputs.BETA_CLI_ENVIRONMENT }}" == "dev" ]; then + elif [ "${{ inputs.BETA_ENVIRONMENT }}" == "dev" ]; then STACKSPOT_IAM_URL="https://iam-auth-ssr.dev.stackspot.com" STACKSPOT_RUNTIME_MANAGER_URL="https://runtime-manager.dev.stackspot.com" + STACKSPOT_WORKSPACE_URL="https://workspace-workspace-api.dev.stackspot.com" else STACKSPOT_IAM_URL="https://auth.stackspot.com" STACKSPOT_RUNTIME_MANAGER_URL="https://runtime-manager.stackspot.com" + STACKSPOT_WORKSPACE_URL="https://workspace.stackspot.com" fi echo "iam=$STACKSPOT_IAM_URL" >> "$GITHUB_OUTPUT" + echo "workspace=$STACKSPOT_WORKSPACE_URL" >> "$GITHUB_OUTPUT" echo "runtime_manager=$STACKSPOT_RUNTIME_MANAGER_URL" >> "$GITHUB_OUTPUT" shell: bash @@ -126,6 +130,7 @@ runs: VERSION_TAG: ${{ inputs.VERSION_TAG }} ENVIRONMENT: ${{ inputs.ENVIRONMENT }} STACKSPOT_IAM_URL: ${{ steps.stackspot-url.outputs.iam }} + STACKSPOT_WORKSPACE_URL: ${{ steps.stackspot-url.outputs.workspace }} STACKSPOT_RUNTIME_MANAGER_URL: ${{ steps.stackspot-url.outputs.runtime_manager }} run: | if [ ${{runner.os}} != 'Windows' ]; then diff --git a/runtime.py b/runtime.py index d8a68e8..2b20d08 100644 --- a/runtime.py +++ b/runtime.py @@ -36,8 +36,8 @@ def build_pipeline_url() -> str: return url -def get_env_id(slug, access_token): - workspace_url = "https://workspace.stackspot.com/v1/environments" +def get_env_id(slug, access_token, workspace_url): + workspace_url = f"{workspace_url}/v1/environments" deploy_headers = {"Authorization": f"Bearer {access_token}", "Content-Type": "application/json"} env_request = requests.get( url=workspace_url, @@ -72,6 +72,7 @@ def get_env_id(slug, access_token): ENVIRONMENT = os.getenv("ENVIRONMENT") STACKSPOT_IAM_URL = os.getenv("STACKSPOT_IAM_URL") STACKSPOT_RUNTIME_MANAGER_URL = os.getenv("STACKSPOT_RUNTIME_MANAGER_URL") +STACKSPOT_WORKSPACE_URL = os.getenv("STACKSPOT_WORKSPACE_URL") inputs_list = [ENVIRONMENT, VERSION_TAG, CLIENT_ID, CLIENT_KEY, CLIENT_REALM, TF_STATE_BUCKET_NAME, TF_STATE_REGION, IAC_BUCKET_NAME, IAC_REGION] @@ -117,7 +118,7 @@ def get_env_id(slug, access_token): request_data = { **stk_id, - "envId": get_env_id(ENVIRONMENT, access_token), + "envId": get_env_id(ENVIRONMENT, access_token, STACKSPOT_WORKSPACE_URL), "tag": VERSION_TAG, "config": { "tfstate": { @@ -149,7 +150,7 @@ def get_env_id(slug, access_token): data=request_data ) elif stk_yaml_type == 'infra': - self_hosted_rollback_infra_url = f"{STACKSPOT_RUNTIME_MANAGER_URL}/run/self-hosted/rollback/infra" + self_hosted_rollback_infra_url = f"{STACKSPOT_RUNTIME_MANAGER_URL}/v1/run/self-hosted/rollback/infra" rollback_request = requests.post( url=self_hosted_rollback_infra_url, headers=deploy_headers,