@@ -437,10 +437,6 @@ func (c *client) UpdatePullRequest(ctx context.Context, gitcmd git.GitInterface,
437437 info * github.GitHubInfo , pullRequests []* github.PullRequest , pr * github.PullRequest ,
438438 commit git.Commit , prevCommit * git.Commit ) {
439439
440- if c .config .User .LogGitHubCalls {
441- fmt .Printf ("> github update %d : %s\n " , pr .Number , pr .Title )
442- }
443-
444440 baseRefName := c .config .Repo .GitHubBranch
445441 if prevCommit != nil {
446442 baseRefName = git .BranchNameFromCommit (c .config , * prevCommit )
@@ -453,6 +449,26 @@ func (c *client) UpdatePullRequest(ctx context.Context, gitcmd git.GitInterface,
453449 templatizer := config_fetcher .PRTemplatizer (c .config , gitcmd )
454450 title := templatizer .Title (info , commit )
455451 body := templatizer .Body (info , commit , pr )
452+
453+ // Skip the API call if nothing has actually changed. This avoids
454+ // triggering a spurious pull_request "edited" event on GitHub which
455+ // would cause a second (duplicate) Actions run after the force-push
456+ // already triggered a "synchronize" event.
457+ titleUnchanged := c .config .User .PreserveTitleAndBody || title == pr .Title
458+ bodyUnchanged := c .config .User .PreserveTitleAndBody || body == pr .Body
459+ baseUnchanged := pr .InQueue || baseRefName == pr .ToBranch
460+ if titleUnchanged && bodyUnchanged && baseUnchanged {
461+ log .Debug ().Int ("number" , pr .Number ).Msg ("UpdatePullRequest: skipping, nothing changed" )
462+ if c .config .User .LogGitHubCalls {
463+ fmt .Printf ("> github update %d : %s (skipped, no changes)\n " , pr .Number , pr .Title )
464+ }
465+ return
466+ }
467+
468+ if c .config .User .LogGitHubCalls {
469+ fmt .Printf ("> github update %d : %s\n " , pr .Number , pr .Title )
470+ }
471+
456472 input := genclient.UpdatePullRequestInput {
457473 PullRequestId : pr .ID ,
458474 Title : & title ,
0 commit comments