Skip to content

Commit

Permalink
BackdropCMS.org issue #948: Race-condition in GitHub Webhooks sometim…
Browse files Browse the repository at this point in the history
…es double-creates releases and project nodes.
  • Loading branch information
quicksketch committed Aug 25, 2024
1 parent b7b6665 commit 53ede84
Showing 1 changed file with 20 additions and 19 deletions.
39 changes: 20 additions & 19 deletions project_github/project_github.module
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,28 @@ function project_github_githubapi_payload($event_name, $record, $repo) {
if (project_github_update_readme($project_node)) {
$project_node->save();
}
break;
break;
case 'release':
$errors = array();
$project_node_result = NULL;
$package_result = _project_github_create_package($errors, $payload);
if ($package_result) {
$project_node_result = _project_github_create_project($errors, $payload);
}
// If a project node was created or already exists, create the release with
// package created above.
if ($project_node_result) {
$release_node_result = _project_github_create_project_release($errors, $payload);
}
// For better reporting for project authors who may not have access to the
// group-wide web hook settings, attempt to upload a report of the failures
// to the release as an asset.
if (!empty($errors)) {
_project_github_upload_error_log($errors, $payload);
if ($payload['action'] === 'published') {
$errors = [];
$project_node_result = NULL;
$package_result = _project_github_create_package($errors, $payload);
if ($package_result) {
$project_node_result = _project_github_create_project($errors, $payload);
}
// If a project node was created or already exists, create the release with
// package created above.
if ($project_node_result) {
$release_node_result = _project_github_create_project_release($errors, $payload);
}
// For better reporting for project authors who may not have access to the
// group-wide web hook settings, attempt to upload a report of the failures
// to the release as an asset.
if (!empty($errors)) {
_project_github_upload_error_log($errors, $payload);
}
}
break;

break;
}
}

Expand Down

0 comments on commit 53ede84

Please sign in to comment.