fix: use commit hash on webhooks

This commit is contained in:
Andras Bacsai 2024-05-15 10:44:45 +02:00
parent 0ffba45517
commit 1e09b2bbd8
4 changed files with 10 additions and 1 deletions

View File

@ -47,7 +47,7 @@ public function manual(Request $request)
if ($x_bitbucket_event === 'repo:push') {
$branch = data_get($payload, 'push.changes.0.new.name');
$full_name = data_get($payload, 'repository.full_name');
$commit = data_get($payload, 'push.changes.0.new.target.hash');
if (!$branch) {
return response([
'status' => 'failed',
@ -104,6 +104,7 @@ public function manual(Request $request)
queue_application_deployment(
application: $application,
deployment_uuid: $deployment_uuid,
commit: $commit,
force_rebuild: false,
is_webhook: true
);

View File

@ -129,6 +129,7 @@ public function manual(Request $request)
application: $application,
deployment_uuid: $deployment_uuid,
force_rebuild: false,
commit: data_get($payload, 'after', 'HEAD'),
is_webhook: true,
);
$return_payloads->push([
@ -177,6 +178,7 @@ public function manual(Request $request)
pull_request_id: $pull_request_id,
deployment_uuid: $deployment_uuid,
force_rebuild: false,
commit: data_get($payload, 'head.sha', 'HEAD'),
is_webhook: true,
git_type: 'github'
);
@ -338,6 +340,7 @@ public function normal(Request $request)
queue_application_deployment(
application: $application,
deployment_uuid: $deployment_uuid,
commit: data_get($payload, 'after', 'HEAD'),
force_rebuild: false,
is_webhook: true,
);
@ -387,6 +390,7 @@ public function normal(Request $request)
pull_request_id: $pull_request_id,
deployment_uuid: $deployment_uuid,
force_rebuild: false,
commit: data_get($payload, 'head.sha', 'HEAD'),
is_webhook: true,
git_type: 'github'
);

View File

@ -133,6 +133,7 @@ public function manual(Request $request)
queue_application_deployment(
application: $application,
deployment_uuid: $deployment_uuid,
commit: data_get($payload, 'after', 'HEAD'),
force_rebuild: false,
is_webhook: true,
);
@ -182,6 +183,7 @@ public function manual(Request $request)
application: $application,
pull_request_id: $pull_request_id,
deployment_uuid: $deployment_uuid,
commit: data_get($payload, 'object_attributes.last_commit.id', 'HEAD'),
force_rebuild: false,
is_webhook: true,
git_type: 'gitlab'

View File

@ -1113,6 +1113,8 @@ private function check_git_if_build_needed()
}
if ($this->saved_outputs->get('git_commit_sha') && !$this->rollback) {
$this->commit = $this->saved_outputs->get('git_commit_sha')->before("\t");
$this->application_deployment_queue->commit = $this->commit;
$this->application_deployment_queue->save();
}
}
private function clone_repository()