-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: #12 watch after the new agent releases
- Loading branch information
1 parent
24450eb
commit 0037a61
Showing
27 changed files
with
454 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
APP_NAME=Laravel | ||
APP_NAME=Ptah.sh | ||
APP_ENV=local | ||
APP_KEY= | ||
APP_DEBUG=true | ||
|
9 changes: 9 additions & 0 deletions
9
app/Events/NodeTasks/ConfirmAgentUpgrade/ConfirmAgentUpgradeCompleted.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace App\Events\NodeTasks\ConfirmAgentUpgrade; | ||
|
||
use App\Events\NodeTasks\BaseTaskEvent; | ||
|
||
class ConfirmAgentUpgradeCompleted extends BaseTaskEvent | ||
{ | ||
} |
9 changes: 9 additions & 0 deletions
9
app/Events/NodeTasks/ConfirmAgentUpgrade/ConfirmAgentUpgradeFailed.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace App\Events\NodeTasks\ConfirmAgentUpgrade; | ||
|
||
use App\Events\NodeTasks\BaseTaskEvent; | ||
|
||
class ConfirmAgentUpgradeFailed extends BaseTaskEvent | ||
{ | ||
} |
9 changes: 9 additions & 0 deletions
9
app/Events/NodeTasks/DownloadAgentUpgrade/DownloadAgentUpgradeCompleted.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace App\Events\NodeTasks\DownloadAgentUpgrade; | ||
|
||
use App\Events\NodeTasks\BaseTaskEvent; | ||
|
||
class DownloadAgentUpgradeCompleted extends BaseTaskEvent | ||
{ | ||
} |
9 changes: 9 additions & 0 deletions
9
app/Events/NodeTasks/DownloadAgentUpgrade/DownloadAgentUpgradeFailed.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace App\Events\NodeTasks\DownloadAgentUpgrade; | ||
|
||
use App\Events\NodeTasks\BaseTaskEvent; | ||
|
||
class DownloadAgentUpgradeFailed extends BaseTaskEvent | ||
{ | ||
} |
9 changes: 9 additions & 0 deletions
9
app/Events/NodeTasks/UpdateAgentSymlink/UpdateAgentSymlinkCompleted.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace App\Events\NodeTasks\UpdateAgentSymlink; | ||
|
||
use App\Events\NodeTasks\BaseTaskEvent; | ||
|
||
class UpdateAgentSymlinkCompleted extends BaseTaskEvent | ||
{ | ||
} |
9 changes: 9 additions & 0 deletions
9
app/Events/NodeTasks/UpdateAgentSymlink/UpdateAgentSymlinkFailed.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<?php | ||
|
||
namespace App\Events\NodeTasks\UpdateAgentSymlink; | ||
|
||
use App\Events\NodeTasks\BaseTaskEvent; | ||
|
||
class UpdateAgentSymlinkFailed extends BaseTaskEvent | ||
{ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace App\Jobs; | ||
|
||
use App\Models\AgentRelease; | ||
use Illuminate\Bus\Queueable; | ||
use Illuminate\Contracts\Queue\ShouldQueue; | ||
use Illuminate\Foundation\Bus\Dispatchable; | ||
use Illuminate\Queue\InteractsWithQueue; | ||
use Illuminate\Queue\SerializesModels; | ||
use Illuminate\Support\Facades\Http; | ||
|
||
class CheckAgentUpdates implements ShouldQueue | ||
{ | ||
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; | ||
|
||
/** | ||
* Create a new job instance. | ||
*/ | ||
public function __construct() | ||
{ | ||
} | ||
|
||
/** | ||
* Execute the job. | ||
*/ | ||
public function handle(): void | ||
{ | ||
$json = Http::get("https://api.github.com/repos/ptah-sh/ptah-agent/releases/latest")->json(); | ||
|
||
foreach ($json['assets'] as $asset) { | ||
preg_match('/^ptah-agent-(?<os>.+)-(?<arch>.+).bin$/', $asset['name'], $matches); | ||
if (empty($matches)) { | ||
continue; | ||
} | ||
|
||
$attrs = [ | ||
'tag_name' => $json['tag_name'], | ||
'download_url' => $asset['browser_download_url'], | ||
'os' => $matches['os'], | ||
'arch' => $matches['arch'], | ||
]; | ||
|
||
AgentRelease::firstOrCreate($attrs, $attrs); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
namespace App\Models; | ||
|
||
use Illuminate\Database\Eloquent\Factories\HasFactory; | ||
use Illuminate\Database\Eloquent\Model; | ||
|
||
class AgentRelease extends Model | ||
{ | ||
use HasFactory; | ||
|
||
protected $fillable = [ | ||
'tag_name', | ||
'download_url', | ||
'os', | ||
'arch', | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
app/Models/NodeTasks/ConfirmAgentUpgrade/ConfirmAgentUpgradeMeta.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
namespace App\Models\NodeTasks\ConfirmAgentUpgrade; | ||
|
||
use App\Models\NodeTasks\AbstractTaskMeta; | ||
|
||
class ConfirmAgentUpgradeMeta extends AbstractTaskMeta | ||
{ | ||
public function __construct( | ||
public string $targetVersion | ||
) | ||
{ | ||
// | ||
} | ||
|
||
public function formattedHtml(): string | ||
{ | ||
return "Confirm agent upgrade to <code>{$this->targetVersion}</code>"; | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
app/Models/NodeTasks/ConfirmAgentUpgrade/ConfirmAgentUpgradeResult.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace App\Models\NodeTasks\ConfirmAgentUpgrade; | ||
|
||
use App\Models\NodeTasks\AbstractTaskResult; | ||
|
||
class ConfirmAgentUpgradeResult extends AbstractTaskResult | ||
{ | ||
public function __construct( | ||
) | ||
{ | ||
// | ||
} | ||
|
||
public function formattedHtml(): string | ||
{ | ||
return "Success."; | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
app/Models/NodeTasks/DownloadAgentUpgrade/DownloadAgentUpgradeMeta.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?php | ||
|
||
namespace App\Models\NodeTasks\DownloadAgentUpgrade; | ||
|
||
use App\Models\NodeTasks\AbstractTaskMeta; | ||
|
||
class DownloadAgentUpgradeMeta extends AbstractTaskMeta | ||
{ | ||
public function __construct( | ||
public string $targetVersion, | ||
public string $downloadUrl | ||
) | ||
{ | ||
// | ||
} | ||
|
||
public function formattedHtml(): string | ||
{ | ||
return "Download agent upgrade to <code>{$this->targetVersion}</code>"; | ||
} | ||
} |
Oops, something went wrong.