Skip to content

Enhance automatic pr preparation#7125

Open
BlackYps wants to merge 5 commits into
developfrom
pr-preparation
Open

Enhance automatic pr preparation#7125
BlackYps wants to merge 5 commits into
developfrom
pr-preparation

Conversation

@BlackYps
Copy link
Copy Markdown
Contributor

@BlackYps BlackYps commented May 17, 2026

Description of the proposed changes

Testing done on the proposed changes

Additional context

Checklist

Summary by CodeRabbit

  • Chores
    • Improved pull request preparation workflow with automated changelog snippet generation.
    • Updated PR handling to draft status on creation.

Review Change Stack

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 17, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4a6b2bd6-1e46-4a3a-9f80-951b0e69e328

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • ✅ Review completed - (🔄 Check again to review again)
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch pr-preparation

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot marked this pull request as draft May 17, 2026 23:26
@BlackYps BlackYps marked this pull request as ready for review May 17, 2026 23:28
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.github/workflows/pr-preparation.yaml:
- Around line 46-52: The workflow always overwrites category.${{
github.event.pull_request.number }}.md by copying template-snippet.md, which can
clobber an author-provided snippet; change the logic around FILE to first check
for file absence and only create/copy when the target does not exist, and when
committing only add that generated filename instead of git add . so you stage
and commit the new FILE (refer to the FILE variable and the cp/sed/git add/git
commit/git push commands) to avoid touching other files in the branch.
- Around line 23-25: Add explicit GITHUB_TOKEN permissions so the
draft-conversion step can run gh pr ready --undo; add a permissions block
granting pull-requests: write (either globally under the workflow root or on the
specific job that runs the draft conversion) and ensure GITHUB_TOKEN is used
there; update the workflow to include permissions: pull-requests: write so the
gh command can undo drafts successfully.

In `@changelog/snippets/category.7125.md`:
- Line 1: The changelog snippet file category.7125.md is still a template;
rename the file to the correct final category name (replace "category" with the
actual category slug for PR 7125) and edit the file contents to remove the
placeholder line "Your explanation here... [Don't forget to change the category
in the filename] (`#7125`)." and replace it with the finalized changelog entry
text for PR 7125 (brief summary, scope, and PR reference). Ensure the new
filename matches the repository's changelog category conventions and the file
body contains the final, publication-ready snippet.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 7d577447-937c-408d-9650-9b894e921d3e

📥 Commits

Reviewing files that changed from the base of the PR and between 2d3c23e and 87289e8.

📒 Files selected for processing (3)
  • .github/workflows/pr-preparation.yaml
  • changelog/snippets/category.7125.md
  • changelog/snippets/sections/template-snippet.md

Comment on lines 23 to 25
on:
pull_request:
types: [opened]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

cat -n .github/workflows/pr-preparation.yaml

Repository: FAForever/fa

Length of output: 2728


🌐 Web query:

gh cli gh pr ready permission requirements contents write vs pull-requests write

💡 Result:

To use the gh pr ready command in a GitHub Actions workflow, you generally need the pull-requests: write permission [1]. While pull-requests: write is the primary requirement for modifying the state of a pull request, the specific permissions required by the GitHub CLI (gh) can be nuanced depending on the repository context and the specific operations being performed [1][2]. Key considerations for permission requirements: 1. Pull-Requests Permission: The pull-requests: write permission is necessary to change the status of a pull request (e.g., marking it as ready or converting it back to a draft) [1][3]. 2. Contents Permission: The contents: write permission is typically required if your workflow involves pushing changes, tags, or other repository modifications [1]. It is not strictly required for the gh pr ready command itself, but it is often included in workflows that perform broader PR management tasks [1]. 3. Additional Scopes: Depending on the complexity of your workflow, you may encounter requirements for other permissions. For example: - repository-projects: read may be required if the CLI attempts to access project metadata associated with the pull request [1]. - issues: read is often necessary for commands like gh pr list, as the CLI may rely on issue-related search or metadata endpoints [2]. - If you are using features like assigning reviewers or teams, you might face limitations with the default GITHUB_TOKEN, which may require a Personal Access Token (PAT) with broader scopes (such as read:org) [4][3]. In summary, while pull-requests: write is the core requirement for gh pr ready, you should configure your workflow permissions based on the full set of gh commands being executed to avoid 403 Forbidden errors [1][5]. If you encounter unexpected failures, check if your workflow requires additional read access to repository projects or issues [1][2].

Citations:


Add explicit permissions for the draft conversion step.

This workflow relies on repo-default GITHUB_TOKEN permissions, but gh pr ready --undo requires pull-requests: write permission. On repos with read-only defaults, this step can fail even though earlier steps succeed.

Suggested fix
 on:
   pull_request:
     types: [opened]
+
+permissions:
+  pull-requests: write
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/pr-preparation.yaml around lines 23 - 25, Add explicit
GITHUB_TOKEN permissions so the draft-conversion step can run gh pr ready
--undo; add a permissions block granting pull-requests: write (either globally
under the workflow root or on the specific job that runs the draft conversion)
and ensure GITHUB_TOKEN is used there; update the workflow to include
permissions: pull-requests: write so the gh command can undo drafts
successfully.

Comment on lines +46 to +52
FILE=category.${{ github.event.pull_request.number }}.md
cp sections/template-snippet.md $FILE
sed -i "s/XYZW/${{ github.event.pull_request.number }}/g" $FILE

git add .
git commit -m "Add snippet template"
git push
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Don't overwrite an author-provided snippet.

This always recreates category.<pr>.md from the template. If the branch already has a real snippet, the workflow replaces it with placeholder text and pushes that regression back to the PR branch. Guard on file absence and only stage the generated file.

Suggested fix
-          FILE=category.${{ github.event.pull_request.number }}.md
-          cp sections/template-snippet.md $FILE
-          sed -i "s/XYZW/${{ github.event.pull_request.number }}/g" $FILE
-          
-          git add .
-          git commit -m "Add snippet template"
-          git push
+          FILE="category.${{ github.event.pull_request.number }}.md"
+          if [ ! -f "$FILE" ]; then
+            cp sections/template-snippet.md "$FILE"
+            sed -i "s/XYZW/${{ github.event.pull_request.number }}/g" "$FILE"
+
+            git add "$FILE"
+            git commit -m "Add snippet template"
+            git push
+          fi
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
FILE=category.${{ github.event.pull_request.number }}.md
cp sections/template-snippet.md $FILE
sed -i "s/XYZW/${{ github.event.pull_request.number }}/g" $FILE
git add .
git commit -m "Add snippet template"
git push
FILE="category.${{ github.event.pull_request.number }}.md"
if [ ! -f "$FILE" ]; then
cp sections/template-snippet.md "$FILE"
sed -i "s/XYZW/${{ github.event.pull_request.number }}/g" "$FILE"
git add "$FILE"
git commit -m "Add snippet template"
git push
fi
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.github/workflows/pr-preparation.yaml around lines 46 - 52, The workflow
always overwrites category.${{ github.event.pull_request.number }}.md by copying
template-snippet.md, which can clobber an author-provided snippet; change the
logic around FILE to first check for file absence and only create/copy when the
target does not exist, and when committing only add that generated filename
instead of git add . so you stage and commit the new FILE (refer to the FILE
variable and the cp/sed/git add/git commit/git push commands) to avoid touching
other files in the branch.

Comment thread changelog/snippets/category.7125.md Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants