mirror of
https://github.com/coollabsio/coolify.git
synced 2026-11-06 13:10:37 -04:00
fix(webhooks): deploy Gitea pull requests at their head commit
The Gitea handler read the pull request commit from a top-level head.sha that Gitea does not send, so preview deployments always used HEAD. It now reads pull_request.head.sha, with the top-level after of newer Gitea versions as a fallback. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
700d476bac
commit
a77fe4d4ed
@@ -58,7 +58,8 @@ class Gitea extends Controller
|
||||
$skip_deploy_pr = self::shouldSkipDeployAny([$this->webhookPayloadString($payload, 'pull_request.title')]);
|
||||
$branch = $this->webhookString(data_get($payload, 'pull_request.head.ref'));
|
||||
$base_branch = $this->webhookString(data_get($payload, 'pull_request.base.ref'));
|
||||
$commit = $this->webhookCommitSha($payload, 'head.sha');
|
||||
// Gitea sends the head commit in pull_request.head.sha; newer versions also send it as after.
|
||||
$commit = $this->webhookCommitSha($payload, 'pull_request.head.sha') ?? $this->webhookCommitSha($payload, 'after');
|
||||
}
|
||||
if (! $branch || ($x_gitea_event === 'pull_request' && ! $base_branch)) {
|
||||
return response('Nothing to do. No branch found in the request.');
|
||||
|
||||
@@ -376,7 +376,7 @@ function webhookTypesFields(): array
|
||||
['pull_request.title', 'string', null],
|
||||
['pull_request.head.ref', 'branch', 'No branch'],
|
||||
['pull_request.base.ref', 'branch', 'No branch'],
|
||||
['head.sha', 'sha', null],
|
||||
['pull_request.head.sha', 'sha', null],
|
||||
['repository.full_name', 'required string', 'Invalid repository'],
|
||||
],
|
||||
'gitea manual|pr|closed' => [
|
||||
@@ -506,7 +506,8 @@ describe('Webhook payload value types', function () {
|
||||
})->with([
|
||||
'gitlab manual' => ['gitlab manual', webhookTypesSha()],
|
||||
'gitlab app' => ['gitlab app', webhookTypesSha()],
|
||||
'gitea manual' => ['gitea manual', 'HEAD'],
|
||||
// Gitea sends the head commit in pull_request.head.sha.
|
||||
'gitea manual' => ['gitea manual', webhookTypesSha()],
|
||||
'bitbucket manual' => ['bitbucket manual', substr(webhookTypesSha(), 0, 12)],
|
||||
]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user