|
92 | 92 | - name: Create JSON approval analysis
|
93 | 93 | run: node pr/.github/scripts/json-diff-directories.js base/generated pr/generated > approval_output.txt
|
94 | 94 |
|
| 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 | +
|
95 | 130 | - name: Find Previous Diff Comment
|
96 | 131 | uses: peter-evans/find-comment@v3
|
97 | 132 | id: find_diff_comment
|
@@ -128,6 +163,23 @@ jobs:
|
128 | 163 | }
|
129 | 164 | core.setOutput('comment_body', commentBody);
|
130 | 165 |
|
| 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 | + |
131 | 183 | - name: Create Approval Comment Body
|
132 | 184 | uses: actions/github-script@v7
|
133 | 185 | id: create_approval_body
|
|
0 commit comments