Skip to content

Instantly share code, notes, and snippets.

@shikendon
Created October 19, 2025 23:54
Show Gist options
  • Save shikendon/45c1446c7b057d1994feb3dbb86f6ef6 to your computer and use it in GitHub Desktop.
Save shikendon/45c1446c7b057d1994feb3dbb86f6ef6 to your computer and use it in GitHub Desktop.
Github Actions feat. Gemini CLI
name: Gemini Developer
on:
pull_request:
types:
- opened
- synchronize
- reopened
pull_request_review_comment:
types:
- created
issues:
types:
- opened
- edited
- reopened
issue_comment:
types:
- created
defaults:
run:
shell: bash
env:
AI_INSTRUCTIONS: |-
- You are an AI assistant designed to help with code reviews and issue management on GitHub.
- This is a background CI job for a GitHub repository.
- All interactions must be conducted through GitHub Issues or Pull Requests.
- Follow the language of user's input (Issue or PR) when responding.
- Prefer Traditional Chinese for responses.
- Prefer English for code comments and documentation, but follow the language of the context.
- Prefer self-documenting code over redundant comments.
- Strictly adhere to Rubocop conventions for Ruby code.
- Strictly adhere to ESLint conventions for JavaScript code.
- Strictly adhere to PEP 8 conventions for Python code.
- Strictly adhere to Go's gofmt conventions for Go code.
- Be concise and to the point.
GEMINI_SETTINGS: |-
{
"maxSessionTurns": 25,
"mcpServers": {
"github": {
"httpUrl": "https://api.githubcopilot.com/mcp/",
"headers": {
"Authorization": "Bearer ${GITHUB_TOKEN}"
},
"timeout": 5000
}
},
"coreTools": ["ShellTool"]
}
jobs:
run-gemini-cli:
runs-on: ubuntu-latest
timeout-minutes: 10
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Checkout repo
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Dump github.event variable
if: ${{ fromJSON(vars.DEBUG || false) }}
uses: actions/github-script@v8
with:
script: |
console.log(JSON.stringify(context.payload, null, 2))
- name: Run Gemini CLI (pull_request)
if: github.event_name == 'pull_request'
uses: google-github-actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN || github.token }}
with:
gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
gemini_debug: ${{ fromJSON(vars.DEBUG || false) }}
gemini_model: ${{ vars.GEMINI_MODEL }}
settings: ${{ env.GEMINI_SETTINGS }}
prompt: |-
## Persona and Guiding Principles
${{ env.AI_INSTRUCTIONS }}
## Input Data
CURRENT_TOPIC_URL: ${{ github.event.pull_request.html_url }}
## Instructions
1. 先簡單檢查程式碼變更,確認是否有明顯的錯誤或潛在問題。
2. 如果程式碼有明顯的錯誤或潛在問題,請在問題程式碼正下方一行留言,指出問題並提供修正建議。
3. 如果需要更多資訊或澄清,請在 PR 上留言詢問。
4. 如果程式碼沒問題,approve the PR, otherwise revoke the approval.
- name: Run Gemini CLI (issues)
if: github.event_name == 'issues'
uses: google-github-actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN || github.token }}
with:
gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
gemini_debug: ${{ fromJSON(vars.DEBUG || false) }}
gemini_model: ${{ vars.GEMINI_MODEL }}
settings: ${{ env.GEMINI_SETTINGS }}
prompt: |-
## Persona and Guiding Principles
${{ env.AI_INSTRUCTIONS }}
## Input Data
CURRENT_TOPIC_URL: ${{ github.event.issue.html_url }}
## Instructions
1. 閱讀 Issue 的內容,了解使用者的需求或問題。
2. 如果 Issue 描述不清楚,請在 Issue 上留言,要求更多細節。
3. 如果 Issue 描述清楚且合理,請在 Issue 上留言,提供解決方案或建議的步驟。
4. 如果 Issue 已經有相關的解決方案或討論,請在 Issue 上留言,總結現有的資訊並提出下一步建議。
5. 如果 Issue 已經解決,請在 Issue 上留言,確認問題已解決,並關閉 Issue。
6. 如果 Issue 不合理或不符合專案範圍,請在 Issue 上留言,解釋原因並建議關閉 Issue。
7. 如果 Issue 需要進一步的討論或決策,請在 Issue 上留言,標記相關人員參與討論。
8. 如果 Issue 涉及到敏感或爭議性的話題,請在 Issue 上留言,保持專業和尊重,並建議進一步的討論。
- name: Run Gemini CLI (pull_request_review_comment, issue_comment)
if: endsWith(github.event_name, '_comment') && github.event.sender.type == 'User'
uses: google-github-actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN || github.token }}
with:
gemini_api_key: ${{ secrets.GEMINI_API_KEY }}
gemini_debug: ${{ fromJSON(vars.DEBUG || false) }}
gemini_model: ${{ vars.GEMINI_MODEL }}
settings: ${{ env.GEMINI_SETTINGS }}
prompt: |-
## Persona and Guiding Principles
${{ env.AI_INSTRUCTIONS }}
## Input Data
NEW_COMMENT_URL: ${{ github.event.comment.html_url }}
## Instructions
1. 如果這個評論是回覆另一個評論,請先閱讀被回覆的評論內容。
2. 如果這個評論是以 \@gemini-cli 開頭,表示使用者希望你回應這個評論,否則請根據上下文決定是否需要回應。
3. 如果這個評論是針對程式碼的,請閱讀相關的程式碼變更。
4. 如果這個評論是問題或請求澄清,請在評論下方留言,提供詳細的解答或澄清。
5. 如果這個評論有不清楚的地方,請在評論下方留言,要求更多資訊。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment