Skip to content

Commit

Permalink
👌 IMPROVE: Rename db column
Browse files Browse the repository at this point in the history
  • Loading branch information
austinginder committed Nov 11, 2024
1 parent 53b47f1 commit 3d26a85
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions app/Providers/Kinsta.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ public static function environments( $kinsta_id ) {
public static function connect_staging( $site_id ) {
$site = ( new \CaptainCore\Sites )->get( $site_id );
$environments = ( new \CaptainCore\Environments )->where( [ "site_id" => $site_id ] );
if ( empty( $site->provider_id ) ) {
if ( empty( $site->provider_site_id ) ) {
return;
}
foreach( $environments as $environment ) {
Expand All @@ -171,7 +171,7 @@ public static function connect_staging( $site_id ) {
}
}
$time_now = date("Y-m-d H:i:s");
$response = \CaptainCore\Remote\Kinsta::get( "sites/{$site->provider_id}/environments" );
$response = \CaptainCore\Remote\Kinsta::get( "sites/{$site->provider_site_id}/environments" );

foreach( $response->site->environments as $kinsta_environment ) {
if ( $kinsta_environment->name == "staging" ) {
Expand Down Expand Up @@ -207,15 +207,15 @@ public static function connect_staging( $site_id ) {
public static function sync_environments( $site_id ) {
$site = ( new \CaptainCore\Sites )->get( $site_id );
$environments = ( new \CaptainCore\Environments )->where( [ "site_id" => $site_id ] );
if ( empty( $site->provider_id ) ) {
if ( empty( $site->provider_site_id ) ) {
return;
}
foreach( $environments as $environment ) {
if ( $environment->environment == "Production" ) {
$production_environment = $environment;
}
}
$response = \CaptainCore\Remote\Kinsta::get( "sites/{$site->provider_id}/environments" );
$response = \CaptainCore\Remote\Kinsta::get( "sites/{$site->provider_site_id}/environments" );

foreach( $response->site->environments as $kinsta_environment ) {
if ( $kinsta_environment->name == "live" ) {
Expand Down Expand Up @@ -247,10 +247,10 @@ public static function sync_environments( $site_id ) {

public static function create_staging_and_deploy( $site_id ) {
$site = ( new \CaptainCore\Sites )->get( $site_id );
if ( empty( $site->provider_id ) ) {
if ( empty( $site->provider_site_id ) ) {
return;
}
$environments = self::environments( $site->provider_id );
$environments = self::environments( $site->provider_site_id );
$environment_production_id = "";
foreach( $environments as $environment ) {
if ( $environment->name == "live" ) {
Expand All @@ -262,15 +262,15 @@ public static function create_staging_and_deploy( $site_id ) {
"is_premium" => false,
"source_env_id" => $environment_production_id
];
$response = \CaptainCore\Remote\Kinsta::post( "sites/{$site->provider_id}/environments/clone", $data );
$response = \CaptainCore\Remote\Kinsta::post( "sites/{$site->provider_site_id}/environments/clone", $data );

$action = (object) [
"command" => "deploy-to-staging",
"step" => 2,
"message" => "Deploying $site->name to staging environment",
"name" => $site->name,
"site_id" => $site_id,
"kinsta_site_id" => $site->provider_id,
"kinsta_site_id" => $site->provider_site_id,
"environment_production_id" => $environment_production_id,
];

Expand All @@ -280,10 +280,10 @@ public static function create_staging_and_deploy( $site_id ) {

public static function deploy_to_staging( $site_id ) {
$site = ( new \CaptainCore\Sites )->get( $site_id );
if ( empty( $site->provider_id ) ) {
if ( empty( $site->provider_site_id ) ) {
return;
}
$environments = self::environments( $site->provider_id );
$environments = self::environments( $site->provider_site_id );
$api_key = self::credentials("api");
$data = [
"tag" => "Deploy to staging from API"
Expand Down Expand Up @@ -321,7 +321,7 @@ public static function deploy_to_staging( $site_id ) {
"name" => $site->name,
"site_id" => $site_id,
"connect_staging" => $connect_staging,
"kinsta_site_id" => $site->provider_id,
"kinsta_site_id" => $site->provider_site_id,
"environment_production_id" => $environment_production_id,
"environment_staging_id" => $environment_staging_id,
];
Expand All @@ -332,10 +332,10 @@ public static function deploy_to_staging( $site_id ) {

public static function deploy_to_production( $site_id ) {
$site = ( new \CaptainCore\Sites )->get( $site_id );
if ( empty( $site->provider_id ) ) {
if ( empty( $site->provider_site_id ) ) {
return;
}
$environments = self::environments( $site->provider_id );
$environments = self::environments( $site->provider_site_id );
$api_key = self::credentials("api");

$environment_production_id = "";
Expand All @@ -355,7 +355,7 @@ public static function deploy_to_production( $site_id ) {
"push_files" => true,
"run_search_and_replace" => true
];
$response = \CaptainCore\Remote\Kinsta::put( "sites/{$site->provider_id}/environments", $data );
$response = \CaptainCore\Remote\Kinsta::put( "sites/{$site->provider_site_id}/environments", $data );

if ( empty ( $response->operation_id ) ) {
return false;
Expand All @@ -374,7 +374,7 @@ public static function deploy_to_production( $site_id ) {
"message" => "Deploying $name to production environment",
"name" => $name,
"site_id" => $site_id,
"kinsta_site_id" => $site->provider_id,
"kinsta_site_id" => $site->provider_site_id,
];

self::add_action( $response->operation_id, $action );
Expand Down Expand Up @@ -423,7 +423,7 @@ public static function provider_sync() {
$site_name = $kinsta_site->environment->primaryDomain->name;
$site_name = str_replace( "www.", "", $site_name );
if ( $site->name == $site_name ) {
( new \CaptainCore\Sites )->update( [ "provider_id" => $kinsta_site->id ], [ "site_id" => $site->site_id ] );
( new \CaptainCore\Sites )->update( [ "provider_site_id" => $kinsta_site->id ], [ "site_id" => $site->site_id ] );
}
}
}
Expand Down

0 comments on commit 3d26a85

Please sign in to comment.