fix: map PlatformException to proper ErrorCode in all methods #376
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Gemini Auto PR | |
| on: | |
| workflow_dispatch: | |
| issues: | |
| types: [labeled] | |
| pull_request: | |
| types: [labeled] | |
| issue_comment: | |
| types: [created] | |
| concurrency: | |
| group: ci-gemini-pr-${{ github.event.issue.number || github.event.pull_request.number || github.run_id }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: write | |
| issues: write | |
| pull-requests: write | |
| id-token: write | |
| jobs: | |
| analyze-and-pr: | |
| runs-on: ubuntu-latest | |
| if: > | |
| ( | |
| github.event_name == 'issues' && | |
| github.event.action == 'labeled' && | |
| contains(github.event.issue.labels.*.name, 'auto-fix') | |
| ) || ( | |
| github.event_name == 'pull_request' && | |
| github.event.action == 'labeled' && | |
| contains(github.event.pull_request.labels.*.name, 'auto-fix') | |
| ) || ( | |
| github.event_name == 'issue_comment' && | |
| contains(github.event.comment.body, '@gemini-cli') && | |
| contains(github.event.comment.body, '/fix') | |
| ) | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Flutter | |
| uses: subosito/flutter-action@v2 | |
| with: | |
| channel: stable | |
| flutter-version: "3.x" | |
| - name: Install dependencies | |
| run: flutter pub get | |
| - name: Analyze issue and create PR if solvable | |
| id: analyze-pr | |
| uses: google-github-actions/run-gemini-cli@v0 | |
| timeout-minutes: 20 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| with: | |
| use_gemini_code_assist: true | |
| gemini_model: "gemini-2.5-pro" | |
| prompt: | | |
| You are an expert Flutter developer helping with the flutter_inapp_purchase package. | |
| Analyze the following issue: ${{ github.event.issue.title || github.event.pull_request.title }} | |
| Issue description: | |
| ${{ github.event.issue.body || github.event.pull_request.body }} | |
| Your task: | |
| 1. Determine if this issue can be automatically resolved with code changes | |
| 2. If it's a bug that can be fixed or a simple feature that can be implemented: | |
| - Create a new branch named 'fix-issue-${{ github.event.issue.number }}' (only if it does not already exist) | |
| - Make the necessary code changes following the CLAUDE.md guidelines | |
| - Ensure all tests pass (flutter test) | |
| - Ensure code is formatted (dart format .) | |
| - Create a pull request that references issue #${{ github.event.issue.number }} | |
| 3. If the issue requires human intervention or discussion: | |
| - Add a comment explaining why it cannot be automatically resolved | |
| - Suggest what information or decisions are needed | |
| Important: | |
| - Follow the API changes and naming conventions in CLAUDE.md | |
| - MUST comply with OpenIAP specification: https://openiap.dev | |
| - APIs: https://openiap.dev/docs/apis | |
| - Types: https://openiap.dev/docs/types | |
| - Events: https://openiap.dev/docs/events | |
| - Errors: https://openiap.dev/docs/errors | |
| - Maintain backward compatibility unless explicitly mentioned in the issue | |
| - Add tests for any new functionality | |
| - Update documentation if needed | |
| Idempotency and Safety Requirements: | |
| - Before deleting any branch, first check existence using: `git rev-parse --verify <branch>`. | |
| Only delete if it exists. Never loop on the same failing command. | |
| - If branch creation fails once, stop and return an error with a single clear message. | |
| - If the Gemini API returns a 429 (quota exceeded), stop immediately and surface the error; do not retry in a loop. | |
| - Never attempt to switch to a branch you are already on; check current branch with `git rev-parse --abbrev-ref HEAD`. | |
| - Keep commands minimal and fail-fast; no repeated attempts of the same action. | |
| Only create a PR if you're confident the solution is correct and complete. | |
| settings: | | |
| { | |
| "tools": [ | |
| { "name": "gh" }, | |
| { "name": "git" }, | |
| { "name": "flutter" }, | |
| { "name": "dart" } | |
| ], | |
| "repositories": [ | |
| { "path": ".", "instructions": "Refer to CLAUDE.md for conventions. Keep changes minimal, add tests, and follow pre-commit checks." } | |
| ], | |
| "model": "gemini-1.5-flash" | |
| } | |
| - name: Comment on issue with result | |
| if: always() | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| const issueNumber = context.issue.number; | |
| const outputs = JSON.parse(process.env.ANALYZE_OUTPUTS || "{}"); | |
| const summary = outputs.summary || ''; | |
| const error = outputs.error || ''; | |
| let comment = ''; | |
| if (error) { | |
| let friendly = ''; | |
| const lower = String(error).toLowerCase(); | |
| if (lower.includes('429') || lower.includes('resource_exhausted') || lower.includes('quota')) { | |
| friendly = '\n\nIt looks like the Gemini API quota was exceeded. Please try again later or switch to a higher-quota model/key. You can retrigger by commenting `@gemini-cli /fix` once quota is available.'; | |
| } | |
| comment = `Failed to analyze or fix the issue:${friendly}\n\n\`\`\`\n${error}\n\`\`\``; | |
| } else if (summary) { | |
| comment = `Gemini Analysis Result:\n${summary}`; | |
| } | |
| if (comment) { | |
| await github.rest.issues.createComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: issueNumber, | |
| body: comment | |
| }); | |
| } | |
| env: | |
| ANALYZE_OUTPUTS: ${{ toJSON(steps.analyze-pr.outputs) }} | |
| auto-pr-on-comment: | |
| runs-on: ubuntu-latest | |
| if: > | |
| github.event_name == 'issue_comment' && | |
| contains(github.event.comment.body, '@gemini-cli') && | |
| contains(github.event.comment.body, '/fix') | |
| steps: | |
| - name: React to comment | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| await github.rest.reactions.createForIssueComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: context.payload.comment.id, | |
| content: 'rocket' | |
| }); |