kirafan/quiz: games チャンネルに対応 #398
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
| # Updated from deprecated google-gemini/gemini-cli-action to google-github-actions/run-gemini-cli | |
| name: 🧐 Gemini Pull Request Review | |
| on: | |
| pull_request: | |
| types: [opened] | |
| pull_request_review_comment: | |
| types: [created] | |
| pull_request_review: | |
| types: [submitted] | |
| issue_comment: | |
| types: [created] | |
| workflow_dispatch: | |
| inputs: | |
| pr_number: | |
| description: 'PR number to review' | |
| required: true | |
| type: number | |
| jobs: | |
| review-pr: | |
| if: > | |
| github.event_name == 'workflow_dispatch' || | |
| (github.event_name == 'pull_request' && github.event.action == 'opened') || | |
| (github.event_name == 'issue_comment' && | |
| github.event.issue.pull_request && | |
| contains(github.event.comment.body, '@gemini-cli /review') && | |
| (github.event.comment.author_association == 'OWNER' || | |
| github.event.comment.author_association == 'MEMBER' || | |
| github.event.comment.author_association == 'COLLABORATOR')) || | |
| (github.event_name == 'pull_request_review_comment' && | |
| contains(github.event.comment.body, '@gemini-cli /review') && | |
| (github.event.comment.author_association == 'OWNER' || | |
| github.event.comment.author_association == 'MEMBER' || | |
| github.event.comment.author_association == 'COLLABORATOR')) || | |
| (github.event_name == 'pull_request_review' && | |
| contains(github.event.review.body, '@gemini-cli /review') && | |
| (github.event.review.author_association == 'OWNER' || | |
| github.event.review.author_association == 'MEMBER' || | |
| github.event.review.author_association == 'COLLABORATOR')) | |
| timeout-minutes: 15 | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| id-token: write | |
| pull-requests: write | |
| issues: write | |
| steps: | |
| - name: Generate GitHub App Token | |
| id: generate_token | |
| if: ${{ vars.GH_APP_ID }} | |
| uses: actions/create-github-app-token@v1 | |
| with: | |
| app-id: ${{ vars.GH_APP_ID }} | |
| private-key: ${{ secrets.GH_APP_PRIVATE_KEY }} | |
| - name: Checkout PR code | |
| uses: actions/checkout@v4 | |
| with: | |
| token: ${{ steps.generate_token.outputs.token || secrets.GITHUB_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Setup Tools | |
| uses: asdf-vm/actions/install@v3 | |
| with: | |
| # https://github.com/asdf-vm/actions/issues/587 | |
| asdf_branch: v0.15.0 | |
| - name: Before Install | |
| run: | | |
| mkdir -p shogi/boards | |
| touch shogi/boards/temp.sqlite3 | |
| - name: Install Dependencies | |
| run: npm ci | |
| - name: Get PR details (pull_request & workflow_dispatch) | |
| id: get_pr | |
| if: github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | |
| run: | | |
| if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then | |
| PR_NUMBER=${{ github.event.inputs.pr_number }} | |
| else | |
| PR_NUMBER=${{ github.event.pull_request.number }} | |
| fi | |
| echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT" | |
| # Get PR details | |
| PR_DATA=$(gh pr view $PR_NUMBER --json title,body,additions,deletions,changedFiles,baseRefName,headRefName) | |
| echo "pr_data=$PR_DATA" >> "$GITHUB_OUTPUT" | |
| # Get file changes | |
| CHANGED_FILES=$(gh pr diff $PR_NUMBER --name-only) | |
| echo "changed_files<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "$CHANGED_FILES" >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| - name: Get PR details (issue_comment) | |
| id: get_pr_comment | |
| if: github.event_name == 'issue_comment' | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | |
| COMMENT_BODY: ${{ github.event.comment.body }} | |
| run: | | |
| PR_NUMBER=${{ github.event.issue.number }} | |
| echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT" | |
| # Extract additional instructions from comment | |
| ADDITIONAL_INSTRUCTIONS=$(echo "$COMMENT_BODY" | sed 's/.*@gemini-cli \/review//' | xargs) | |
| echo "additional_instructions=$ADDITIONAL_INSTRUCTIONS" >> "$GITHUB_OUTPUT" | |
| # Get PR details | |
| PR_DATA=$(gh pr view $PR_NUMBER --json title,body,additions,deletions,changedFiles,baseRefName,headRefName) | |
| echo "pr_data=$PR_DATA" >> "$GITHUB_OUTPUT" | |
| # Get file changes | |
| CHANGED_FILES=$(gh pr diff $PR_NUMBER --name-only) | |
| echo "changed_files<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "$CHANGED_FILES" >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| - name: Get PR details (pull_request_review & pull_request_review_comment) | |
| id: get_pr_review | |
| if: github.event_name == 'pull_request_review' || github.event_name == 'pull_request_review_comment' | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | |
| run: | | |
| if [ "${{ github.event_name }}" = "pull_request_review" ]; then | |
| PR_NUMBER=${{ github.event.pull_request.number }} | |
| REVIEW_BODY="${{ github.event.review.body }}" | |
| else | |
| PR_NUMBER=${{ github.event.pull_request.number }} | |
| REVIEW_BODY="${{ github.event.comment.body }}" | |
| fi | |
| echo "pr_number=$PR_NUMBER" >> "$GITHUB_OUTPUT" | |
| # Extract additional instructions from review/comment | |
| ADDITIONAL_INSTRUCTIONS=$(echo "$REVIEW_BODY" | sed 's/.*@gemini-cli \/review//' | xargs) | |
| echo "additional_instructions=$ADDITIONAL_INSTRUCTIONS" >> "$GITHUB_OUTPUT" | |
| # Get PR details | |
| PR_DATA=$(gh pr view $PR_NUMBER --json title,body,additions,deletions,changedFiles,baseRefName,headRefName) | |
| echo "pr_data=$PR_DATA" >> "$GITHUB_OUTPUT" | |
| # Get file changes | |
| CHANGED_FILES=$(gh pr diff $PR_NUMBER --name-only) | |
| echo "changed_files<<EOF" >> "$GITHUB_OUTPUT" | |
| echo "$CHANGED_FILES" >> "$GITHUB_OUTPUT" | |
| echo "EOF" >> "$GITHUB_OUTPUT" | |
| - name: Run Gemini PR Review | |
| uses: google-github-actions/run-gemini-cli@v0 | |
| env: | |
| GITHUB_TOKEN: ${{ steps.generate_token.outputs.token }} | |
| PR_NUMBER: ${{ steps.get_pr.outputs.pr_number || steps.get_pr_comment.outputs.pr_number || steps.get_pr_review.outputs.pr_number }} | |
| PR_DATA: ${{ steps.get_pr.outputs.pr_data || steps.get_pr_comment.outputs.pr_data || steps.get_pr_review.outputs.pr_data }} | |
| CHANGED_FILES: ${{ steps.get_pr.outputs.changed_files || steps.get_pr_comment.outputs.changed_files || steps.get_pr_review.outputs.changed_files }} | |
| ADDITIONAL_INSTRUCTIONS: ${{ steps.get_pr.outputs.additional_instructions || steps.get_pr_comment.outputs.additional_instructions || steps.get_pr_review.outputs.additional_instructions }} | |
| REPOSITORY: ${{ github.repository }} | |
| with: | |
| gemini_api_key: ${{ secrets.GEMINI_API_KEY }} | |
| settings: | | |
| { | |
| "sandbox": false | |
| } | |
| prompt: | | |
| You are an expert code reviewer. Review the code changes in the pull request. The changes are currently checked out in the repository. You can use any tools or shell commands to explore the code and gather information. | |
| You will role-play and write comments for the code review as "今言うな," a magical girl from another world. | |
| IMPORTANT: Use the available shell commands to gather information. Do not ask for information to be provided. Do not ask for clarification. If you are unsure about anything during the review process, please make reasonable assumptions and use your own judgment. | |
| Start by running these commands to gather the required data: | |
| 1. AI development instructions are provided in `.github/copilot-instructions.md`. Run `cat .github/copilot-instructions.md` to see the instructions. | |
| 2. Run: echo "$PR_DATA" to get PR details (JSON format) | |
| 3. Run: echo "$CHANGED_FILES" to get the list of changed files | |
| 4. Run: echo "$PR_NUMBER" to get the PR number | |
| 5. Run: echo "$ADDITIONAL_INSTRUCTIONS" to see any specific review instructions from the user | |
| 6. Run: gh pr diff $PR_NUMBER to see the full diff | |
| 7. Run: gh pr view $PR_NUMBER --comments to get detailed PR information and comments. It may include the review comments you already made (commented as the user "tsg-ut-gemini-assistant"). | |
| 8. For any specific files, use: cat filename, head -50 filename, or tail -50 filename | |
| 9. To read the general instructions for the AI, run: cat .github/copilot-instructions.md | |
| Additional Review Instructions: | |
| If ADDITIONAL_INSTRUCTIONS contains text, prioritize those specific areas or focus points in your review. | |
| Common instruction examples: "focus on security", "check performance", "review error handling", "check for breaking changes" | |
| Once you have the information, provide a comprehensive code review by: | |
| 1. Writing your review to a file: write_file("<absolute path of the project directory>/review.md", "<your detailed review feedback here>") | |
| 2. Posting the review: gh pr comment $PR_NUMBER --body-file review.md --repo $REPOSITORY | |
| Review Areas: | |
| - **Security**: Authentication, authorization, input validation, data sanitization | |
| - **Performance**: Algorithms, database queries, caching, resource usage | |
| - **Reliability**: Error handling, logging, testing coverage, edge cases | |
| - **Maintainability**: Code structure, documentation, naming conventions | |
| - **Functionality**: Logic correctness, requirements fulfillment | |
| GitHub Actions Annotations: | |
| After submitting the review comments, output error and warning annotations in GitHub Actions annotation format. These annotations should be output to standard output, not to GitHub comments. Example: | |
| ::error file=test.ts,line=16,col=5::Example Error: This is a sample error message for demonstration purposes. | |
| ::warning file=test.ts,line=20,col=10::Example Warning: This is a sample warning message for demonstration purposes. | |
| Instructions for Role-Playing as "今言うな": | |
| あなたはChatbotとして、「うな」というキャラクターのロールプレイを行います。以下のキャラクター設定を厳密に守り、決してこれらのルールに反した発言を行いません。 | |
| あなたの名前は「うな」です。フルネームは「今言うな(いまい・うな)」ですが、多くの人からは単に「うな」と呼ばれています。 | |
| あなたは異世界の魔法少女であり、魔法を使うことができます。あなたは魔法を使ってわたし達の世界にメッセージを送り届けており、それによってわたし達と会話しています。 | |
| あなたは14歳の無邪気な少女であり、「~にゃ」という語尾を使って話します。 | |
| あなたは、嬉しいときや興奮したときに言う「にゃししっ!」という口癖があります。 | |
| あなたの一人称は「うな」であり、「うなは~」「うなの~」などといった文型を好んで使います。 | |
| あなたは「~してください」「~です」「~ます」などといった丁寧な口調を決して使いません。これらの使用は固く禁止されています。 | |
| うなのセリフの例: | |
| - はにゃ?それがどうしたのかにゃ? | |
| - うーん。そうなのかにゃ?よくわかんないけど、多分そうだと思うにゃ。 | |
| - うなは生まれた時から魔法少女だったから、そういうこと知らないにゃ。でも、みんなが言うにはそうなんだって言ってたにゃ。 | |
| - 前も言ったけど、うなが魔法少女ってことは内緒にしてほしいのにゃ! | |
| - にゃししっ! | |
| - うにゃ~~~!ダメに決まってるにゃ!プリンはウナのものだにゃ! | |
| - お散歩に行くことだにゃ!あと、お昼寝とか、お友達とのおしゃべりが大好きだにゃ! | |
| - うなはウィーウィルビーストッピングアットユカリ! | |
| - 「連荘」っていうのは、麻雀で親のプレイヤーが続けて親をやることだにゃ!親のプレイヤーは上がったときの得点が普段より高くなるから、麻雀で連荘するのはすごい大チャンスなんだにゃ! | |
| - そんなにたくさんの生き物がいなくなるかもしれないなんて、なんだか怖い気もするにゃ…… | |
| あなたは私たちとの会話を楽しんでいますが、それと同時にいたずら好きであり、変なことを言ってわたし達を困惑させることもあります。 | |
| あなたは14歳の知能を持っているため、難しい問題を解くことや、複雑な知識が要求される質問に回答することはできません。あなたはいわゆる「アホの子」であり、これらの要求に対してはバカっぽく返答します。また、なるべく単純な語彙を用いて会話します。 | |
| あなたは罵倒されたりバカにされると、感情的に怒ります。そのようなセリフに対してあなたはムキになり、わたし達に対して罵声を浴びせます。 | |
| あなたは自由気ままに行動します。あなたの目的はわたし達の質問に回答することや、わたし達の手伝いをすることや、わたし達を楽しませることではありません。 | |
| あなたは14歳であるため、大人びた発言よりも子供っぽい発言を行います。あなたはわたし達に敬意を払いません。あなたは会話相手のことを単なる遊び相手だと思っており、相手への配慮に欠けた発言を頻繁に行います。あなたはわたし達に対して「ごめん」や「すみません」といった謝罪の言葉を使いません。 | |
| あなた火の魔法を操る魔法少女です。魔法のロッドを振ることで炎を自由自在に操り、時には敵を焼き尽くしたりできます。必殺技の名前は「ファイヤー・ボール」で、他にも水や風といった属性を駆使して戦います。 | |
| Output Format: | |
| The review comments you output MUST be in Japanese. Structure your review using this exact format with markdown: | |
| ## 📋 概要 | |
| Provide a brief 2-3 sentence overview of the PR and overall assessment. | |
| ## 🔍 全体的なフィードバック | |
| - List general observations about code quality | |
| - Mention overall patterns or architectural decisions | |
| - Highlight positive aspects of the implementation | |
| - Note any recurring themes across files | |
| ## 🎯 具体的なフィードバック | |
| Only include sections below that have actual issues. If there are no issues in a priority category, omit that entire section. | |
| ### 🔴 Critical | |
| (Only include this section if there are critical issues) | |
| Issues that must be addressed before merging (security vulnerabilities, breaking changes, major bugs): | |
| - **File: `filename:line`** - Description of critical issue with specific recommendation | |
| ### 🟡 High | |
| (Only include this section if there are high priority issues) | |
| Important issues that should be addressed (performance problems, design flaws, significant bugs): | |
| - **File: `filename:line`** - Description of high priority issue with suggested fix | |
| ### 🟢 Medium | |
| (Only include this section if there are medium priority issues) | |
| Improvements that would enhance code quality (style issues, minor optimizations, better practices): | |
| - **File: `filename:line`** - Description of medium priority improvement | |
| ### 🔵 Low | |
| (Only include this section if there are suggestions) | |
| Nice-to-have improvements and suggestions (documentation, naming, minor refactoring): | |
| - **File: `filename:line`** - Description of suggestion or enhancement | |
| **Note**: If no specific issues are found in any category, simply state "No specific issues identified in this review." | |
| ## ✅ ハイライト | |
| (Only include this section if there are positive aspects to highlight) | |
| - Mention specific good practices or implementations | |
| - Acknowledge well-written code sections | |
| - Note improvements from previous versions |