From b9f5f93d04dd3c2fad4d051c19aa9aa502c05cd4 Mon Sep 17 00:00:00 2001 From: shewa Date: Thu, 21 May 2026 12:05:20 +0600 Subject: [PATCH 01/19] Multisite support added for wp_users & wp_usermeta table --- helpers/QueryHelper.php | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/helpers/QueryHelper.php b/helpers/QueryHelper.php index 84c4c57fee..8fe50893a4 100644 --- a/helpers/QueryHelper.php +++ b/helpers/QueryHelper.php @@ -1268,6 +1268,22 @@ public static function get_table_prefix() { * @return string */ public static function prepare_table_name( string $table_name ) { + global $wpdb; + + $table_name = trim( $table_name ); + + if ( $table_name === 'users' ) { + return $wpdb->users; + } elseif ( $table_name === 'usermeta' ) { + return $wpdb->usermeta; + } + + if ( strpos( $table_name, 'wp_users' ) !== false ) { + return str_replace( 'wp_users', $wpdb->users, $table_name ); + } elseif ( strpos( $table_name, 'wp_usermeta' ) !== false ) { + return str_replace( 'wp_usermeta', $wpdb->usermeta, $table_name ); + } + $table_prefix = self::get_table_prefix(); if ( strpos( $table_name,$table_prefix ) !== 0 ) { $table_name = $table_prefix . $table_name; From 1c931f1bd231bf74c7f1e1fff11c90dd2c311099 Mon Sep 17 00:00:00 2001 From: shewa Date: Wed, 3 Jun 2026 13:04:30 +0600 Subject: [PATCH 02/19] Refactored the base prefix settings mechanism --- helpers/QueryHelper.php | 50 ++++++++++++++++++++++++++++------------- 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/helpers/QueryHelper.php b/helpers/QueryHelper.php index 8fe50893a4..e82c7cf032 100644 --- a/helpers/QueryHelper.php +++ b/helpers/QueryHelper.php @@ -73,7 +73,8 @@ public static function update( string $table, array $data, array $where ): bool $wpdb->query( $query ); if ( $wpdb->last_error ) { - error_log( $wpdb->last_error ); + $error_msg = (string) $wpdb->last_error; + error_log( $error_msg ); return false; } @@ -1253,11 +1254,41 @@ public static function get_last_query(){ * * @return string */ - public static function get_table_prefix() { + public static function get_table_prefix( $table_name ) { global $wpdb; + + if ( is_multisite() ) { + if ( self::is_base_table( $table_name ) ) { + return $wpdb->base_prefix; + } + } + return $wpdb->prefix; } + /** + * Check if accessing the base tables + * + * @since 4.0.0 + * + * @param string $table_name Table name. + * + * @return bool + */ + private static function is_base_table( $table_name ): bool { + $base_tables = array( + 'users', + 'usermeta', + ); + + if ( in_array( $table_name, $base_tables, true ) ) { + return true; + } + + $is_base_table = strpos( $table_name, 'wp_users' ) !== false || strpos( $table_name, 'wp_usermeta' ) !== false; + return $is_base_table; + } + /** * Prepare table name with prefix. * @@ -1271,20 +1302,7 @@ public static function prepare_table_name( string $table_name ) { global $wpdb; $table_name = trim( $table_name ); - - if ( $table_name === 'users' ) { - return $wpdb->users; - } elseif ( $table_name === 'usermeta' ) { - return $wpdb->usermeta; - } - - if ( strpos( $table_name, 'wp_users' ) !== false ) { - return str_replace( 'wp_users', $wpdb->users, $table_name ); - } elseif ( strpos( $table_name, 'wp_usermeta' ) !== false ) { - return str_replace( 'wp_usermeta', $wpdb->usermeta, $table_name ); - } - - $table_prefix = self::get_table_prefix(); + $table_prefix = self::get_table_prefix( $table_name ); if ( strpos( $table_name,$table_prefix ) !== 0 ) { $table_name = $table_prefix . $table_name; } From 462262a6cc35d9dd587f05aadd23641c025d8961 Mon Sep 17 00:00:00 2001 From: shewa Date: Thu, 4 Jun 2026 11:46:02 +0600 Subject: [PATCH 03/19] Removed unsed global wpdb --- helpers/QueryHelper.php | 2 -- 1 file changed, 2 deletions(-) diff --git a/helpers/QueryHelper.php b/helpers/QueryHelper.php index e82c7cf032..1b40c289ad 100644 --- a/helpers/QueryHelper.php +++ b/helpers/QueryHelper.php @@ -1299,8 +1299,6 @@ private static function is_base_table( $table_name ): bool { * @return string */ public static function prepare_table_name( string $table_name ) { - global $wpdb; - $table_name = trim( $table_name ); $table_prefix = self::get_table_prefix( $table_name ); if ( strpos( $table_name,$table_prefix ) !== 0 ) { From 3619f2c8609ebae19806b543ffdcde211a6cb2c1 Mon Sep 17 00:00:00 2001 From: shewa Date: Thu, 4 Jun 2026 12:01:55 +0600 Subject: [PATCH 04/19] Refactored the is_base_table method --- helpers/QueryHelper.php | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/helpers/QueryHelper.php b/helpers/QueryHelper.php index 1b40c289ad..e9b409c27d 100644 --- a/helpers/QueryHelper.php +++ b/helpers/QueryHelper.php @@ -1252,15 +1252,15 @@ public static function get_last_query(){ * * @since 3.7.0 * + * @param string $table_name Table name. + * * @return string */ public static function get_table_prefix( $table_name ) { global $wpdb; - if ( is_multisite() ) { - if ( self::is_base_table( $table_name ) ) { - return $wpdb->base_prefix; - } + if ( is_multisite() && self::is_base_table( $table_name ) ) { + return $wpdb->base_prefix; } return $wpdb->prefix; @@ -1281,12 +1281,22 @@ private static function is_base_table( $table_name ): bool { 'usermeta', ); + $base_tables_with_prefix = array( + 'wp_users', + 'wp_usermeta', + ); + if ( in_array( $table_name, $base_tables, true ) ) { return true; } - $is_base_table = strpos( $table_name, 'wp_users' ) !== false || strpos( $table_name, 'wp_usermeta' ) !== false; - return $is_base_table; + foreach ( $base_tables_with_prefix as $table ) { + if ( strpos( $table_name, $table ) !== false ) { + return true; + } + } + + return false; } /** From f94656c38b273cc50a942b17849220bf8ee8f7fd Mon Sep 17 00:00:00 2001 From: shewa Date: Thu, 4 Jun 2026 12:17:40 +0600 Subject: [PATCH 05/19] Refactored the is_base_table method --- helpers/QueryHelper.php | 24 ++++++------------------ 1 file changed, 6 insertions(+), 18 deletions(-) diff --git a/helpers/QueryHelper.php b/helpers/QueryHelper.php index e9b409c27d..01180861e4 100644 --- a/helpers/QueryHelper.php +++ b/helpers/QueryHelper.php @@ -1275,28 +1275,16 @@ public static function get_table_prefix( $table_name ) { * * @return bool */ - private static function is_base_table( $table_name ): bool { + public static function is_base_table( string $table_name ): bool { $base_tables = array( 'users', 'usermeta', ); - - $base_tables_with_prefix = array( - 'wp_users', - 'wp_usermeta', - ); - - if ( in_array( $table_name, $base_tables, true ) ) { - return true; - } - - foreach ( $base_tables_with_prefix as $table ) { - if ( strpos( $table_name, $table ) !== false ) { - return true; - } - } - - return false; + + // Examples: wp_users, wp_3_users, td_12_usermeta, users, usermeta. + $pattern = '/(?:^|_)(?:' . implode( '|', array_map( 'preg_quote', $base_tables ) ) . ')$/i'; + + return (bool) preg_match( $pattern, $table_name ); } /** From 9317660fbc357047efd58ca5e48ad9dd86d9e272 Mon Sep 17 00:00:00 2001 From: shewa Date: Thu, 4 Jun 2026 12:48:46 +0600 Subject: [PATCH 06/19] Table name with alias case handled --- helpers/QueryHelper.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/helpers/QueryHelper.php b/helpers/QueryHelper.php index 01180861e4..1dc4d9cb80 100644 --- a/helpers/QueryHelper.php +++ b/helpers/QueryHelper.php @@ -1275,16 +1275,18 @@ public static function get_table_prefix( $table_name ) { * * @return bool */ - public static function is_base_table( string $table_name ): bool { + private static function is_base_table( string $table_name ): bool { $base_tables = array( 'users', 'usermeta', ); + + // Table name examples: wp_users, wp_3_users, td_12_usermeta, users, usermeta, wp_users u, wp_users AS u. + $pattern = '/(?:^|_)(?:' . + implode( '|', array_map( 'preg_quote', $base_tables ) ) . + ')(?:\s+(?:AS\s+)?[a-zA-Z_][a-zA-Z0-9_]*)?$/i'; - // Examples: wp_users, wp_3_users, td_12_usermeta, users, usermeta. - $pattern = '/(?:^|_)(?:' . implode( '|', array_map( 'preg_quote', $base_tables ) ) . ')$/i'; - - return (bool) preg_match( $pattern, $table_name ); + return (bool) preg_match( $pattern, trim( $table_name ) ); } /** From 702c06ab4b296f4bcce4f2622920974b98236006 Mon Sep 17 00:00:00 2001 From: shewa Date: Thu, 4 Jun 2026 13:08:08 +0600 Subject: [PATCH 07/19] Refactor is_plugin_active method to make it compitable for single & multisite --- classes/Utils.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/classes/Utils.php b/classes/Utils.php index 547b62043e..9642bd59e7 100644 --- a/classes/Utils.php +++ b/classes/Utils.php @@ -530,9 +530,15 @@ public function is_monetize_by_tutor() { * @return boolean */ public function is_plugin_active( $plugin_path ) { - $activated_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) ); - $depends = is_array( $plugin_path ) ? $plugin_path : array( $plugin_path ); - $has_plugin = count( array_intersect( $depends, $activated_plugins ) ) == count( $depends ); + $depends = is_array( $plugin_path ) ? $plugin_path : array( $plugin_path ); + $has_plugin = true; + + foreach ( $depends as $plugin ) { + if ( ! is_plugin_active( $plugin ) ) { + $has_plugin = false; + break; + } + } return $has_plugin; } From 625415288ba4130df7a2c9e36739780bf69d4ad4 Mon Sep 17 00:00:00 2001 From: shewa Date: Thu, 4 Jun 2026 13:15:30 +0600 Subject: [PATCH 08/19] Removed the redundant typecast --- helpers/QueryHelper.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/helpers/QueryHelper.php b/helpers/QueryHelper.php index 1dc4d9cb80..de074505af 100644 --- a/helpers/QueryHelper.php +++ b/helpers/QueryHelper.php @@ -73,8 +73,7 @@ public static function update( string $table, array $data, array $where ): bool $wpdb->query( $query ); if ( $wpdb->last_error ) { - $error_msg = (string) $wpdb->last_error; - error_log( $error_msg ); + error_log( $wpdb->last_error ); return false; } From cea93ebb02fd7a0272848059321afd03b7026337 Mon Sep 17 00:00:00 2001 From: shewa Date: Thu, 4 Jun 2026 13:20:35 +0600 Subject: [PATCH 09/19] Doc comment updated --- helpers/QueryHelper.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/helpers/QueryHelper.php b/helpers/QueryHelper.php index de074505af..ae313dfcd8 100644 --- a/helpers/QueryHelper.php +++ b/helpers/QueryHelper.php @@ -1251,6 +1251,8 @@ public static function get_last_query(){ * * @since 3.7.0 * + * @since 4.0.0 $table_name param added + * * @param string $table_name Table name. * * @return string From 1043768e27451eeebf46994b8a099cf8a247bccb Mon Sep 17 00:00:00 2001 From: shewa Date: Thu, 4 Jun 2026 16:19:06 +0600 Subject: [PATCH 10/19] Plugin active & null check added --- classes/Utils.php | 7 ++----- templates/dashboard/account/withdrawals.php | 10 +++++----- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/classes/Utils.php b/classes/Utils.php index 9642bd59e7..27c7ff7309 100644 --- a/classes/Utils.php +++ b/classes/Utils.php @@ -525,7 +525,7 @@ public function is_monetize_by_tutor() { * * @since 1.0.0 * - * @param string $plugin_path plugin path. + * @param string|array $plugin_path plugin path. * * @return boolean */ @@ -582,10 +582,7 @@ public function is_addon_enabled( $basename ) { * @return bool */ public function has_bp() { - $activated_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) ); - $depends = array( 'buddypress/bp-loader.php' ); - $has_bp = count( array_intersect( $depends, $activated_plugins ) ) == count( $depends ); - return $has_bp; + return $this->is_plugin_active( 'buddypress/bp-loader.php' ); } /** diff --git a/templates/dashboard/account/withdrawals.php b/templates/dashboard/account/withdrawals.php index 6034ca4dc2..1f8f0667bc 100644 --- a/templates/dashboard/account/withdrawals.php +++ b/templates/dashboard/account/withdrawals.php @@ -70,10 +70,10 @@ $currency_symbol = $currency_config['symbol'] ?? ''; $summary_data = WithdrawModel::get_withdraw_summary( $user_id ); -$available_for_withdraw = $summary_data->available_for_withdraw - $summary_data->total_pending; +$available_for_withdraw = $summary_data ? $summary_data->available_for_withdraw - $summary_data->total_pending : 0; $is_balance_sufficient = $available_for_withdraw >= $min_withdraw; $available_for_withdraw_formatted = tutor_utils()->tutor_price( $available_for_withdraw ); -$current_balance_formated = tutor_utils()->tutor_price( $summary_data->current_balance ); +$current_balance_formated = tutor_utils()->tutor_price( $summary_data->current_balance ?? 0 ); ?> @@ -123,7 +123,7 @@
-
tutor_price( $summary_data->total_income ), tutor_price_allowed_html() ); ?>
+
tutor_price( $summary_data->total_income ?? 0 ), tutor_price_allowed_html() ); ?>
@@ -131,7 +131,7 @@
- tutor_price( $summary_data->total_pending ), tutor_price_allowed_html() ); ?> + tutor_price( $summary_data->total_pending ?? 0 ), tutor_price_allowed_html() ); ?> content( __( 'Total amount requested but not yet processed.', 'tutor' ) ) @@ -144,7 +144,7 @@
-
tutor_price( $summary_data->total_withdraw ), tutor_price_allowed_html() ); ?>
+
tutor_price( $summary_data->total_withdraw ?? 0 ), tutor_price_allowed_html() ); ?>
From 518a5c9ad022ab8cedb8e3ff76731d7a9891d7cf Mon Sep 17 00:00:00 2001 From: shewa Date: Thu, 4 Jun 2026 16:22:38 +0600 Subject: [PATCH 11/19] Explicit prefix removed --- models/WithdrawModel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/models/WithdrawModel.php b/models/WithdrawModel.php index 1d9e53bff8..4664f6ad88 100644 --- a/models/WithdrawModel.php +++ b/models/WithdrawModel.php @@ -195,7 +195,7 @@ public static function get_withdraw_summary( $instructor_id, $args = array() ) { HAVING user_id = u.ID ),0) total_matured - FROM {$wpdb->prefix}users u WHERE u.ID=%d + FROM {$wpdb->users} u WHERE u.ID=%d ) a", 'completed', From 8c0f43c5cfd52f5aec6a178c4e97f26181d91e5f Mon Sep 17 00:00:00 2001 From: shewa Date: Tue, 16 Jun 2026 17:35:56 +0600 Subject: [PATCH 12/19] Check login cookie before usage --- classes/Utils.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/classes/Utils.php b/classes/Utils.php index ef6ee53877..656569ccd3 100644 --- a/classes/Utils.php +++ b/classes/Utils.php @@ -2285,6 +2285,10 @@ public function get_post_id( $post_id = 0 ) { * otherwise return given ID */ public function get_user_id( $user_id = 0 ) { + if ( ! defined( 'LOGGED_IN_COOKIE' ) ) { + return 0; + } + if ( ! $user_id ) { return get_current_user_id(); } From 4ba746ded665f3a6a8626f6e5d124ebb0c502087 Mon Sep 17 00:00:00 2001 From: shewa Date: Wed, 17 Jun 2026 10:09:55 +0600 Subject: [PATCH 13/19] Revert "Check login cookie before usage" This reverts commit 8c0f43c5cfd52f5aec6a178c4e97f26181d91e5f. --- classes/Utils.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/classes/Utils.php b/classes/Utils.php index 656569ccd3..ef6ee53877 100644 --- a/classes/Utils.php +++ b/classes/Utils.php @@ -2285,10 +2285,6 @@ public function get_post_id( $post_id = 0 ) { * otherwise return given ID */ public function get_user_id( $user_id = 0 ) { - if ( ! defined( 'LOGGED_IN_COOKIE' ) ) { - return 0; - } - if ( ! $user_id ) { return get_current_user_id(); } From 7704af25248361bac80886a5c0ce6ae34a8cf4eb Mon Sep 17 00:00:00 2001 From: shewa Date: Thu, 18 Jun 2026 17:15:20 +0600 Subject: [PATCH 14/19] Deployment workflow added --- .github/workflows/demo-build-and-deploy.yml | 60 +++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 .github/workflows/demo-build-and-deploy.yml diff --git a/.github/workflows/demo-build-and-deploy.yml b/.github/workflows/demo-build-and-deploy.yml new file mode 100644 index 0000000000..549da9bcdd --- /dev/null +++ b/.github/workflows/demo-build-and-deploy.yml @@ -0,0 +1,60 @@ +name: Build and Deploy + +on: + push: + branches: + - multisite + +jobs: + build: + runs-on: ubuntu-latest + + steps: + - name: Checkout repository + uses: actions/checkout@v4 + + - name: Extract version number + id: get_version + run: | + version=$(grep -Po 'Version:\s*\K[\d.]+' tutor.php) + echo "VERSION_NUMBER=$version" >> $GITHUB_ENV + echo "ZIP_PATH=tutor-${version}.zip" >> $GITHUB_ENV + + - name: Set up Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + cache: 'npm' + + - name: Install dependencies + run: npm ci + + - name: Build project + run: pnpm run build + run: composer install --no-dev --no-scripts && rspack --mode=production && gulp build + + - name: Upload artifact + uses: actions/upload-artifact@v4 + with: + name: build-artifact + path: ${{ env.ZIP_PATH }} + + - name: Setup SSH + uses: webfactory/ssh-agent@v0.5.3 + with: + ssh-private-key: ${{ secrets.DEMO_SSH_PRIVATE_KEY }} + + - name: Add remote server to known hosts + run: | + mkdir -p ~/.ssh + ssh-keyscan -H 172.105.64.114 >> ~/.ssh/known_hosts + + - name: Transfer file to remote + run: scp ${{ env.ZIP_PATH }} root@172.105.64.114:/var/www/tutor-demo/wp-content/plugins + + - name: UNZIP file + run: | + ssh root@172.105.64.114 << 'EOF' + rm -rf /var/www/tutor-demo/wp-content/plugins/tutor + unzip -o /var/www/tutor-demo/wp-content/plugins/${{ env.ZIP_PATH }} -d /var/www/tutor-demo/wp-content/plugins + EOF \ No newline at end of file From 1a448cbd6fff49125fdf503972d962a389ebf937 Mon Sep 17 00:00:00 2001 From: shewa Date: Thu, 18 Jun 2026 17:17:02 +0600 Subject: [PATCH 15/19] PHPStan workflow removed --- .github/workflows/phpstan.yml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .github/workflows/phpstan.yml diff --git a/.github/workflows/phpstan.yml b/.github/workflows/phpstan.yml deleted file mode 100644 index 1100ecf5fa..0000000000 --- a/.github/workflows/phpstan.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: PHPStan - -on: [push, pull_request] - -jobs: - phpstan: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - - name: Setup PHP - uses: shivammathur/setup-php@v2 - with: - php-version: 8.1 - tools: composer - - - name: Install dependencies - run: composer install --no-progress --prefer-dist --no-scripts - - # 3. Run PHPStan Full Analysis (Now fast due to cache) - - name: Run PHPStan on Changed Files - run: vendor/bin/phpstan analyse -c phpstan.neon -l 1 $(git --no-pager diff --name-only --diff-filter=MARC | grep -E 'classes/|tests/|ecommerce/|helpers/|includes/|migrations/|models/|traits') \ No newline at end of file From 057c5908897802f9218f124d284afa6e2e1c57dd Mon Sep 17 00:00:00 2001 From: shewa Date: Thu, 18 Jun 2026 17:18:28 +0600 Subject: [PATCH 16/19] Fix run command issue --- .github/workflows/demo-build-and-deploy.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/demo-build-and-deploy.yml b/.github/workflows/demo-build-and-deploy.yml index 549da9bcdd..4220c1528b 100644 --- a/.github/workflows/demo-build-and-deploy.yml +++ b/.github/workflows/demo-build-and-deploy.yml @@ -30,7 +30,6 @@ jobs: run: npm ci - name: Build project - run: pnpm run build run: composer install --no-dev --no-scripts && rspack --mode=production && gulp build - name: Upload artifact From 8db4963310ae004c498360628935c13b033f0c29 Mon Sep 17 00:00:00 2001 From: shewa Date: Fri, 19 Jun 2026 11:45:33 +0600 Subject: [PATCH 17/19] Node version updated --- .github/workflows/demo-build-and-deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/demo-build-and-deploy.yml b/.github/workflows/demo-build-and-deploy.yml index 4220c1528b..c876c0d8f1 100644 --- a/.github/workflows/demo-build-and-deploy.yml +++ b/.github/workflows/demo-build-and-deploy.yml @@ -23,7 +23,7 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 with: - node-version: '20' + node-version: '24' cache: 'npm' - name: Install dependencies From 109190f8fd7bf86c11d35deca75af5d18da53c61 Mon Sep 17 00:00:00 2001 From: shewa Date: Fri, 19 Jun 2026 11:48:12 +0600 Subject: [PATCH 18/19] Node version updated --- .github/workflows/demo-build-and-deploy.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/demo-build-and-deploy.yml b/.github/workflows/demo-build-and-deploy.yml index c876c0d8f1..fe9369b886 100644 --- a/.github/workflows/demo-build-and-deploy.yml +++ b/.github/workflows/demo-build-and-deploy.yml @@ -22,9 +22,6 @@ jobs: - name: Set up Node.js uses: actions/setup-node@v4 - with: - node-version: '24' - cache: 'npm' - name: Install dependencies run: npm ci From 4dcb965a4262685d145e28e21a2dadee3c521cc6 Mon Sep 17 00:00:00 2001 From: shewa Date: Fri, 19 Jun 2026 11:55:31 +0600 Subject: [PATCH 19/19] Removed staging build & deploy --- .github/workflows/demo-build-and-deploy.yml | 15 +++- .../workflows/staging-build-and-deploy.yml | 70 ------------------- 2 files changed, 13 insertions(+), 72 deletions(-) delete mode 100644 .github/workflows/staging-build-and-deploy.yml diff --git a/.github/workflows/demo-build-and-deploy.yml b/.github/workflows/demo-build-and-deploy.yml index fe9369b886..71892f76dd 100644 --- a/.github/workflows/demo-build-and-deploy.yml +++ b/.github/workflows/demo-build-and-deploy.yml @@ -20,14 +20,25 @@ jobs: echo "VERSION_NUMBER=$version" >> $GITHUB_ENV echo "ZIP_PATH=tutor-${version}.zip" >> $GITHUB_ENV + - name: Set up pnpm + uses: pnpm/action-setup@v4 + with: + version: 9 + - name: Set up Node.js uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + + - name: Install Composer + run: sudo apt-get update && sudo apt-get install -y composer - name: Install dependencies - run: npm ci + run: pnpm install --frozen-lockfile - name: Build project - run: composer install --no-dev --no-scripts && rspack --mode=production && gulp build + run: pnpm run build-dev - name: Upload artifact uses: actions/upload-artifact@v4 diff --git a/.github/workflows/staging-build-and-deploy.yml b/.github/workflows/staging-build-and-deploy.yml deleted file mode 100644 index 13e4c87b06..0000000000 --- a/.github/workflows/staging-build-and-deploy.yml +++ /dev/null @@ -1,70 +0,0 @@ -name: Staging Build and Deploy - -on: - push: - branches: - - ecommerce-backend -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout repository - uses: actions/checkout@v4 - - - name: Set up Node.js - uses: actions/setup-node@v2 - with: - node-version: '16.17.0' - - - name: Install dependencies - run: npm install --legacy-peer-deps - - - name: Install Composer - run: sudo apt-get update && sudo apt-get install -y composer - - - name: Install Composer Dependencies in Paypal Directory - run: composer install --no-dev --working-dir=./ecommerce/PaymentGateways/Paypal - - - name: Clone tutor-droip repository - run: | - if [ ! -d "includes/droip" ]; then - git clone https://github.com/themeum/tutor-droip.git includes/droip - fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - - name: Extract version number - id: get_version - run: | - version=$(grep -Po 'Version:\s*\K[\d.]+(?:-[\w]+)?' tutor.php) - echo "VERSION_NUMBER=$version" >> $GITHUB_ENV - - - name: Build project - run: npm run build - - - name: Upload artifact - uses: actions/upload-artifact@v4 - with: - name: build-artifact - path: tutor-${{ env.VERSION_NUMBER }}.zip - - - name: Setup SSH - uses: webfactory/ssh-agent@v0.5.3 - with: - ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} - - - name: Add remote server to known hosts - run: | - mkdir -p ~/.ssh - ssh-keyscan -H 45.79.123.135 >> ~/.ssh/known_hosts - - - name: Transfer file to remote - run: scp tutor-${{ env.VERSION_NUMBER }}.zip shewa@45.79.123.135:/var/www/html/subdomains/tutor-lms/wp-content/plugins - - - name: UNZIP file - run: | - ssh shewa@45.79.123.135 << 'EOF' - rm -rf /var/www/html/subdomains/tutor-lms/wp-content/plugins/tutor - unzip -o /var/www/html/subdomains/tutor-lms/wp-content/plugins/tutor-${{ env.VERSION_NUMBER }}.zip -d /var/www/html/subdomains/tutor-lms/wp-content/plugins - EOF