A platform for community discussion. Free, open, simple.
DEV: Fix check-pr-body in rebase cases (#40472)
Jarek Radoszf4fc9ca50ce6
diff --git a/.github/workflows/check-pr-body.yml b/.github/workflows/check-pr-body.ymlindex 80bf770905c..81e5a53f4c1 100644--- a/.github/workflows/check-pr-body.yml+++ b/.github/workflows/check-pr-body.yml@@ -2,7 +2,7 @@ name: check-pr-bodyon:pull_request_target:- types: [opened, reopened, edited]+ types: [opened, reopened, edited, synchronize]jobs:sanitize:@@ -14,17 +14,20 @@ jobs:- name: Checkoutuses: actions/checkout@v6with:- ref: ${{ github.event.pull_request.head.sha }}+ ref: ${{ github.event.pull_request.head.sha }}- name: "Replace PR body with commit message"shell: ruby {0}- env:- PR_BODY: ${{ github.event.pull_request.body }}+ env:PR_NUMBER: ${{ github.event.number }}GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}run: |- original_description = ENV['PR_BODY']+ pr_number = ENV['PR_NUMBER']- if !original_description.include? "Dependabot commands and options"+ # Event's payload body can be stale, re-fetch.+ original_description = `gh pr view #{pr_number} --json body --jq .body`+ raise "Failed to fetch PR body" unless $?.success?++ if !original_description.include? "<details>"puts "PR body does not contain rich Dependabot content, skipping"exit 0end@@ -36,7 +39,7 @@ jobs:puts "Updating body to commit message...\n\n---\n#{new_description}\n---"- system "gh", "pr", "edit", ENV['PR_NUMBER'], "--body", new_description+ system "gh", "pr", "edit", pr_number, "--body", new_descriptioncomment = <<~COMMENTPR body updated to plaintext for easier squash-merging. Original body content below:@@ -47,7 +50,7 @@ jobs:COMMENTputs "Adding comment with original info..."- command = ["gh", "pr", "comment", ENV['PR_NUMBER'], "--body", comment]+ command = ["gh", "pr", "comment", pr_number, "--body", comment]beginsystem *command, "--edit-last", exception: truerescue