diff --git a/actions/setup/js/create_pull_request.cjs b/actions/setup/js/create_pull_request.cjs index f2a47731604..01341957ec3 100644 --- a/actions/setup/js/create_pull_request.cjs +++ b/actions/setup/js/create_pull_request.cjs @@ -2794,11 +2794,12 @@ ${patchPreview}`; const fallbackTemplatePath = getPromptPath("pr_permission_denied_fallback.md"); const fallbackBody = renderTemplateFromFile(fallbackTemplatePath, { - body: issueSafeBody, + main_body: issueSafeMainBodyContent, branch_name: branchName, create_pr_url: createPrUrl, faq_url: FAQ_CREATE_PR_PERMISSIONS_URL, patch_preview: patchPreview, + footer: footerContent, }); try { diff --git a/actions/setup/js/create_pull_request.test.cjs b/actions/setup/js/create_pull_request.test.cjs index 46a5959c0d5..823a82b8b46 100644 --- a/actions/setup/js/create_pull_request.test.cjs +++ b/actions/setup/js/create_pull_request.test.cjs @@ -2114,6 +2114,10 @@ ${diffs} expect(createCall.body).toContain("/compare/main..."); expect(createCall.body).not.toContain("gh run download"); expect(createCall.body).not.toContain("git am --3way"); + expect(createCall.body).toContain("Your pull request is ready to create! πŸŽ‰ βœ…"); + expect(createCall.body).toContain("The original pull request description is below."); + expect(createCall.body.indexOf("Your pull request is ready to create! πŸŽ‰ βœ…")).toBeLessThan(createCall.body.indexOf("Test body")); + expect(createCall.body.indexOf("Test body")).toBeLessThan(createCall.body.indexOf("Protected files")); }); it("should push branch with compare URL for protected-files fallback (bundle transport)", async () => { @@ -3658,6 +3662,23 @@ describe("create_pull_request - copilot assignee on fallback issues", () => { expect(issueCall.body).not.toContain("Closes #57"); expect(issueCall.body).not.toContain("Resolves test-owner/test-repo#58"); }); + + it("should keep permission details before the footer in the fallback issue body", async () => { + global.github.rest.pulls.create.mockRejectedValue(new Error("GitHub Actions is not permitted to create or approve pull requests")); + + const { main } = require("./create_pull_request.cjs"); + const handler = await main({ allow_empty: true }); + await handler({ title: "Test PR", body: "Permission path body" }, {}); + + const issueBody = global.github.rest.issues.create.mock.calls[0][0].body; + const tipIndex = issueBody.indexOf("Your pull request is ready to create! πŸŽ‰ βœ…"); + const bodyIndex = issueBody.indexOf("Permission path body"); + const noteIndex = issueBody.indexOf("GitHub Actions is not permitted"); + const footerIndex = issueBody.indexOf(""); + expect(tipIndex).toBeLessThan(bodyIndex); + expect(bodyIndex).toBeLessThan(noteIndex); + expect(noteIndex).toBeLessThan(footerIndex); + }); }); describe("create_pull_request - threat detection caution", () => { diff --git a/actions/setup/md/manifest_protection_create_pr_fallback.md b/actions/setup/md/manifest_protection_create_pr_fallback.md index cb71506ea56..335bcc6e739 100644 --- a/actions/setup/md/manifest_protection_create_pr_fallback.md +++ b/actions/setup/md/manifest_protection_create_pr_fallback.md @@ -1,13 +1,22 @@ +> [!TIP] +> **Your pull request is ready to create! πŸŽ‰ βœ…** +> +> Everything is OKβ€”the changes have been pushed to a branch. Please review the protected files, then create the pull request when you are ready. +> +> **[Create the pull request]({create_pr_url})** +> +> The original pull request description is below. + +--- + {main_body} --- -> [!WARNING] -> **Protected Files** -> -> This was originally intended as a pull request, but the patch modifies protected files. These files may affect project dependencies, CI/CD pipelines, or agent behaviour. **Please review the changes carefully** before creating the pull request. +> [!NOTE] +> **Protected files** > -> **[Click here to create the pull request once you have reviewed the changes]({create_pr_url})** +> This patch modifies protected files, which may affect project dependencies, CI/CD pipelines, or agent behaviour. > >
> Protected files diff --git a/actions/setup/md/pr_permission_denied_fallback.md b/actions/setup/md/pr_permission_denied_fallback.md index cfb402a9a36..f44f4685f19 100644 --- a/actions/setup/md/pr_permission_denied_fallback.md +++ b/actions/setup/md/pr_permission_denied_fallback.md @@ -1,11 +1,23 @@ -{body} +> [!TIP] +> **Your pull request is ready to create! πŸŽ‰ βœ…** +> +> Everything is OKβ€”the changes have been pushed to branch `{branch_name}`. Please review the changes, including any protected files, before creating the pull request. +> +> **[Create the pull request]({create_pr_url})** +> +> The original pull request description is below. + +--- + +{main_body} --- > [!NOTE] -> This was originally intended as a pull request, but GitHub Actions is not permitted to create or approve pull requests in this repository. -> The changes have been pushed to branch `{branch_name}`. -> -> **[Click here to create the pull request]({create_pr_url})** +> GitHub Actions is not permitted to create or approve pull requests in this repository. + +> The changes have been pushed to branch `{branch_name}` and are ready to review. To fix the permissions issue, go to **Settings** β†’ **Actions** β†’ **General** and enable **Allow GitHub Actions to create and approve pull requests**. See also: [gh-aw FAQ]({faq_url}){patch_preview} + +{footer}