mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-21 17:23:37 -07:00
Fix PR workflow.
This commit is contained in:
@@ -90,6 +90,15 @@ jobs:
|
||||
ENABLE_PRS: "${{ github.event.inputs.enable_prs || 'false' }}"
|
||||
run: 'node bundle/gemini.js --policy tools/gemini-cli-bot/ci-policy.toml tools/gemini-cli-bot/brain/metrics.md'
|
||||
|
||||
- name: 'Generate Patch'
|
||||
if: "${{ github.event.inputs.enable_prs == 'true' }}"
|
||||
run: |
|
||||
git add .
|
||||
git diff --staged > bot-changes.patch
|
||||
# Ensure file exists even if empty so upload-artifact doesn't fail if we decide to upload it
|
||||
touch bot-changes.patch
|
||||
touch pr-description.md
|
||||
|
||||
- name: 'Stash Brain Outputs'
|
||||
uses: 'actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02' # ratchet:actions/upload-artifact@v4
|
||||
with:
|
||||
@@ -97,6 +106,8 @@ jobs:
|
||||
path: |
|
||||
tools/gemini-cli-bot/lessons-learned.md
|
||||
tools/gemini-cli-bot/reflexes/scripts/
|
||||
bot-changes.patch
|
||||
pr-description.md
|
||||
retention-days: 1
|
||||
|
||||
publish:
|
||||
@@ -104,16 +115,57 @@ jobs:
|
||||
needs: reasoning
|
||||
runs-on: 'ubuntu-latest'
|
||||
if: "github.repository == 'google-gemini/gemini-cli'"
|
||||
# The publish phase is now just for archiving artifacts to preserve state.
|
||||
# The publish phase is for archiving artifacts and optionally creating PRs.
|
||||
permissions:
|
||||
contents: 'write'
|
||||
pull-requests: 'write'
|
||||
actions: 'write'
|
||||
steps:
|
||||
- name: 'Checkout'
|
||||
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
- name: 'Download Brain Outputs'
|
||||
uses: 'actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093' # ratchet:actions/download-artifact@v4
|
||||
with:
|
||||
name: 'brain-outputs'
|
||||
path: 'temp_outputs/'
|
||||
|
||||
- name: 'Create PR from Patch'
|
||||
if: "${{ github.event.inputs.enable_prs == 'true' }}"
|
||||
env:
|
||||
GITHUB_TOKEN: '${{ secrets.GITHUB_TOKEN }}'
|
||||
run: |
|
||||
if [ -s temp_outputs/bot-changes.patch ]; then
|
||||
git config user.name "github-actions[bot]"
|
||||
git config user.email "github-actions[bot]@users.noreply.github.com"
|
||||
|
||||
BRANCH_NAME="bot/productivity-updates-$(date +'%Y%m%d%H%M%S')"
|
||||
git checkout -b "$BRANCH_NAME"
|
||||
|
||||
git apply temp_outputs/bot-changes.patch
|
||||
git add .
|
||||
|
||||
if [ -s temp_outputs/pr-description.md ]; then
|
||||
git commit -F temp_outputs/pr-description.md
|
||||
else
|
||||
git commit -m "🤖 Gemini Bot Productivity Optimizations"
|
||||
fi
|
||||
|
||||
git push origin "$BRANCH_NAME"
|
||||
|
||||
PR_TITLE="🤖 Gemini Bot Productivity Optimizations"
|
||||
if [ -s temp_outputs/pr-description.md ]; then
|
||||
PR_TITLE=$(head -n 1 temp_outputs/pr-description.md)
|
||||
fi
|
||||
|
||||
gh pr create --draft --title "$PR_TITLE" --body-file temp_outputs/pr-description.md --head "$BRANCH_NAME" --base main || \
|
||||
gh pr create --draft --title "🤖 Gemini Bot Productivity Optimizations" --body "Automated changes generated by Gemini CLI Bot." --head "$BRANCH_NAME" --base main
|
||||
else
|
||||
echo "No patch found or patch is empty. Skipping PR creation."
|
||||
fi
|
||||
|
||||
- name: 'Archive Lessons Learned'
|
||||
uses: 'actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02' # ratchet:actions/upload-artifact@v4
|
||||
with:
|
||||
|
||||
@@ -59,6 +59,15 @@ repository health.
|
||||
terminal escalations to prevent spam.
|
||||
- Recommend specific changes to GitHub Workflows, Triage scripts, or repository
|
||||
`CONTRIBUTING.md`/`GEMINI.md` guidelines.
|
||||
- **Pull Request Preparation**: If the `ENABLE_PRS` environment variable is
|
||||
`true` and you are proposing script or configuration changes, you MUST
|
||||
generate a file named `pr-description.md` in the root directory. This file
|
||||
will be used as both the commit message and PR description. The file MUST
|
||||
include:
|
||||
1. What the change is.
|
||||
2. Why it is recommended.
|
||||
3. Which metric is expected to be improved.
|
||||
4. By how much the metric is expected to improve.
|
||||
|
||||
### 7. Execution Constraints
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# This policy guarantees permission for shell commands and file writing in the bot's CI environment.
|
||||
|
||||
[[rule]]
|
||||
toolName = ["run_shell_command", "write_file"]
|
||||
toolName = ["run_shell_command", "write_file", "replace"]
|
||||
decision = "allow"
|
||||
# Max priority to ensure it overrides all default and workspace rules.
|
||||
priority = 999
|
||||
|
||||
Reference in New Issue
Block a user