feat(projects): track template & duplicate deployment onboarding via the API hook

Add functions/sites createTemplateDeployment and createDuplicateDeployment to
the onboarding config so the existing api.php shutdown hook marks them in the
API request context (which reaches the central console DB), instead of the
regional build worker. Reverts the build-worker write and the Onboarding helper.
This commit is contained in:
Damodar Lohani committed 2026-06-28 06:27:02 +00:00
1 parent 0fe49223b7
commit aacab8fcf1
3 files changed
+10 -73

No files matched your search

+10 -10
View File
@@ -40,11 +40,11 @@ return [
// Functions
'functions.create' => true,
// One key per deployment creation type (deployment `type` attribute);
// OR them in the UI for a single "created a deployment" milestone.
'functions.createManualDeployment' => true,
'functions.createCliDeployment' => true,
'functions.createVcsDeployment' => true,
// One key per deployment-creation SDK method; OR them in the UI for a
// single "created a deployment" milestone.
'functions.createDeployment' => true,
'functions.createTemplateDeployment' => true,
'functions.createDuplicateDeployment' => true,
'functions.updateFunctionDeployment' => true,
// Messaging
@@ -67,10 +67,10 @@ return [
// Sites
'sites.create' => true,
// One key per deployment creation type (deployment `type` attribute);
// OR them in the UI for a single "created a deployment" milestone.
'sites.createManualDeployment' => true,
'sites.createCliDeployment' => true,
'sites.createVcsDeployment' => true,
// One key per deployment-creation SDK method; OR them in the UI for a
// single "created a deployment" milestone.
'sites.createDeployment' => true,
'sites.createTemplateDeployment' => true,
'sites.createDuplicateDeployment' => true,
'sites.updateSiteDeployment' => true,
];
-1
View File
@@ -171,7 +171,6 @@ const ACTOR_TYPE_GUEST = 'guest';
const ACTOR_TYPE_KEY_PROJECT = 'keyProject';
const ACTOR_TYPE_KEY_ACCOUNT = 'keyAccount';
const ACTOR_TYPE_KEY_ORGANIZATION = 'keyOrganization';
const ACTOR_TYPE_SYSTEM = 'system';
/**
* Project onboarding stage status (stored per SDK method key under project.onboarding JSON).
@@ -1039,68 +1039,6 @@ class Builds extends Action
Span::add('build.activated', true);
}
/**
* Mark deployment onboarding stages. Done here (not via the HTTP sdk
* label) so every creation path - manual upload, CLI, template,
* duplicate and VCS - and the worker-driven activation are covered.
* The create stage is keyed by the deployment `type` so each type
* has its own stage (OR them in the UI for a single milestone).
*/
$collection = $resource->getCollection();
$createStage = match ($collection) {
'functions' => match ($deployment->getAttribute('type')) {
'manual' => 'functions.createManualDeployment',
'cli' => 'functions.createCliDeployment',
'vcs' => 'functions.createVcsDeployment',
default => null,
},
'sites' => match ($deployment->getAttribute('type')) {
'manual' => 'sites.createManualDeployment',
'cli' => 'sites.createCliDeployment',
'vcs' => 'sites.createVcsDeployment',
default => null,
},
default => null,
};
$activateStage = match ($collection) {
'functions' => 'functions.updateFunctionDeployment',
'sites' => 'sites.updateSiteDeployment',
default => null,
};
$stages = [];
if ($createStage !== null) {
$stages[] = $createStage;
}
if ($activateBuild && $activateStage !== null) {
$stages[] = $activateStage;
}
if ($stages !== []) {
// Fetch the project fresh and only set stages that aren't already
// recorded, so a stage skipped or completed via the API while the
// build was running is left untouched (??= respects it).
$onboarding = $dbForPlatform->getDocument('projects', $project->getId())->getAttribute('onboarding', []);
if (! \is_array($onboarding)) {
$onboarding = [];
}
foreach ($stages as $stage) {
$onboarding[$stage] ??= [
'status' => ONBOARDING_STATUS_COMPLETED,
'at' => DateTime::now(),
'actorType' => ACTOR_TYPE_SYSTEM,
];
}
try {
$dbForPlatform->updateDocument('projects', $project->getId(), new Document([
'onboarding' => $onboarding,
]));
} catch (\Throwable) {
}
}
$resource = $this->updateLatestDeployment($dbForProject, $resource);
$this->afterDeploymentSuccess(