refactor: migrate plugin updates from GitHub to Mahgit
Build plugin release / release (push) Failing after 5s
Build plugin release / release (push) Failing after 5s
This commit is contained in:
@@ -4,9 +4,9 @@ namespace Dabestaniha\AuthenticateBridge\App\Support;
|
||||
|
||||
final class PluginUpdater
|
||||
{
|
||||
private const API_URL = 'https://api.github.com/repos/dabestaniha/mahak-authenticate-bridge/releases/latest';
|
||||
private const API_URL = 'https://mahgit.ir/api/v1/repos/dabestaniha/mahak-authenticate-bridge/releases/latest';
|
||||
private const RELEASE_ASSET = 'mahak-authenticate-bridge.zip';
|
||||
private const RELEASE_CACHE = 'mahak_authenticate_bridge_release';
|
||||
private const RELEASE_CACHE = 'mahak_authenticate_bridge_gitea_release';
|
||||
private const CHECK_ACTION = 'mahak_authenticate_check_updates';
|
||||
|
||||
private static ?self $instance = null;
|
||||
@@ -74,7 +74,7 @@ final class PluginUpdater
|
||||
'slug' => $this->slug,
|
||||
'version' => $this->releaseVersion($release),
|
||||
'author' => 'Dabestaniha',
|
||||
'homepage' => $release['html_url'] ?? 'https://github.com/dabestaniha/mahak-authenticate-bridge',
|
||||
'homepage' => $release['html_url'] ?? 'https://mahgit.ir/dabestaniha/mahak-authenticate-bridge',
|
||||
'download_link' => $package,
|
||||
'requires_php' => '7.4',
|
||||
'sections' => [
|
||||
@@ -177,30 +177,30 @@ final class PluginUpdater
|
||||
|
||||
$response = wp_remote_get(self::API_URL, [
|
||||
'headers' => [
|
||||
'Accept' => 'application/vnd.github+json',
|
||||
'Accept' => 'application/json',
|
||||
'User-Agent' => 'Mahak-Authenticate-Bridge/'.MAHAK_AUTHENTICATE_BRIDGE_VERSION,
|
||||
],
|
||||
'timeout' => 10,
|
||||
]);
|
||||
|
||||
if (is_wp_error($response)) {
|
||||
return new \WP_Error('mahak_update_request_failed', 'Could not contact GitHub to check for plugin updates.');
|
||||
return new \WP_Error('mahak_update_request_failed', 'Could not contact Mahgit to check for plugin updates.');
|
||||
}
|
||||
|
||||
if (wp_remote_retrieve_response_code($response) !== 200) {
|
||||
return new \WP_Error('mahak_update_response_invalid', 'No published plugin release is currently available on GitHub.');
|
||||
return new \WP_Error('mahak_update_response_invalid', 'No published plugin release is currently available on Mahgit.');
|
||||
}
|
||||
|
||||
$release = json_decode(wp_remote_retrieve_body($response), true);
|
||||
|
||||
if (!is_array($release) || !empty($release['draft']) || !empty($release['prerelease'])) {
|
||||
return new \WP_Error('mahak_update_release_invalid', 'GitHub returned invalid plugin release information.');
|
||||
return new \WP_Error('mahak_update_release_invalid', 'Mahgit returned invalid plugin release information.');
|
||||
}
|
||||
|
||||
if ($this->releaseVersion($release) === '' || $this->releasePackage($release) === null) {
|
||||
return new \WP_Error(
|
||||
'mahak_update_asset_missing',
|
||||
'The latest GitHub release does not contain a valid mahak-authenticate-bridge.zip package.'
|
||||
'The latest Mahgit release does not contain a valid mahak-authenticate-bridge.zip package.'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -228,7 +228,7 @@ final class PluginUpdater
|
||||
if (
|
||||
$url !== ''
|
||||
&& wp_parse_url($url, PHP_URL_SCHEME) === 'https'
|
||||
&& wp_parse_url($url, PHP_URL_HOST) === 'github.com'
|
||||
&& wp_parse_url($url, PHP_URL_HOST) === 'mahgit.ir'
|
||||
&& strpos($path, '/dabestaniha/mahak-authenticate-bridge/releases/download/') === 0
|
||||
) {
|
||||
return $url;
|
||||
|
||||
Reference in New Issue
Block a user