Skip to content

Commit c35744f

Browse files
Add cursor prerequisite check and approve PR (#3665)
* Add cursor prerequisite check and approve PR * Change to squash * Change filter back * Just approve without squash
1 parent e54875c commit c35744f

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

.github/workflows/auto-respond-pr.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,41 @@ jobs:
9292
- name: Create JSON approval analysis
9393
run: node pr/.github/scripts/json-diff-directories.js base/generated pr/generated > approval_output.txt
9494

95+
- name: Check changed files
96+
id: check_files
97+
run: |
98+
cd pr
99+
# Get list of changed files
100+
changed_files=$(git diff --name-only origin/${{ github.event.pull_request.base.ref }}...HEAD)
101+
echo "Changed files:"
102+
echo "$changed_files"
103+
104+
# Check if all changed files are JSON files in overrides/ or features/
105+
valid_changes=true
106+
while IFS= read -r file; do
107+
if [[ ! "$file" =~ ^(overrides|features)/.+\.json$ ]]; then
108+
echo "❌ Invalid file change detected: $file"
109+
echo "Only JSON files in overrides/ and features/ directories are allowed for auto-approval"
110+
valid_changes=false
111+
fi
112+
done <<< "$changed_files"
113+
114+
if [ "$valid_changes" = true ]; then
115+
echo "✅ All changed files are valid JSON files in allowed directories"
116+
echo "files_valid=true" >> $GITHUB_OUTPUT
117+
else
118+
echo "files_valid=false" >> $GITHUB_OUTPUT
119+
fi
120+
121+
- name: Parse approval output
122+
id: approval
123+
run: |
124+
if grep -q "AUTO-APPROVED" approval_output.txt; then
125+
echo "approved=true" >> $GITHUB_OUTPUT
126+
else
127+
echo "approved=false" >> $GITHUB_OUTPUT
128+
fi
129+
95130
- name: Find Previous Diff Comment
96131
uses: peter-evans/find-comment@v3
97132
id: find_diff_comment
@@ -128,6 +163,23 @@ jobs:
128163
}
129164
core.setOutput('comment_body', commentBody);
130165
166+
- name: Wait for Cursor Bugbot
167+
uses: fountainhead/action-wait-for-check@v1.2.0
168+
id: wait-for-build
169+
with:
170+
token: ${{ secrets.GITHUB_TOKEN }}
171+
checkName: Cursor Bugbot
172+
ref: ${{ github.event.pull_request.head.sha }}
173+
timeoutSeconds: 600
174+
175+
- name: Auto approve
176+
if: steps.wait-for-build.outputs.conclusion == 'success' && steps.approval.outputs.approved == 'true' && steps.check_files.outputs.files_valid == 'true'
177+
run: |
178+
gh pr review --approve "$PR_URL"
179+
env:
180+
PR_URL: ${{ github.event.pull_request.html_url }}
181+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
182+
131183
- name: Create Approval Comment Body
132184
uses: actions/github-script@v7
133185
id: create_approval_body

0 commit comments

Comments
 (0)