From 9a656b4dd3b8279aebfca81a72c8a238c9af2301 Mon Sep 17 00:00:00 2001 From: Emily Hedlund Date: Tue, 28 Apr 2026 11:09:08 -0400 Subject: [PATCH 1/2] chore: align workflows with best practices and fix workspace trust regression --- .github/workflows/gemini-invoke.yml | 36 ++++++++++++++----- .github/workflows/gemini-issue-fixer.yml | 26 ++++++++++++++ .github/workflows/gemini-plan-execute.yml | 36 ++++++++++++++----- .github/workflows/gemini-review.yml | 27 +++++++++----- .github/workflows/gemini-scheduled-triage.yml | 24 +++++++++---- .github/workflows/gemini-triage.yml | 21 ++++++++--- 6 files changed, 131 insertions(+), 39 deletions(-) diff --git a/.github/workflows/gemini-invoke.yml b/.github/workflows/gemini-invoke.yml index 5bec70a52..d404e375d 100644 --- a/.github/workflows/gemini-invoke.yml +++ b/.github/workflows/gemini-invoke.yml @@ -39,11 +39,36 @@ jobs: - name: 'Checkout Code' uses: 'actions/checkout@v4' # ratchet:exclude + with: + persist-credentials: 'false' + + - name: 'Prepare prompt context' + shell: 'bash' + run: |- + mkdir -p .gemini + jq -n \ + --arg title "${TITLE}" \ + --arg desc "${DESCRIPTION}" \ + --arg event "${EVENT_NAME}" \ + --arg pr "${IS_PULL_REQUEST}" \ + --arg num "${ISSUE_NUMBER}" \ + --arg repo "${REPOSITORY}" \ + --arg context "${ADDITIONAL_CONTEXT}" \ + '{title: $title, description: $desc, event_name: $event, is_pull_request: $pr, issue_number: $num, repository: $repo, additional_context: $context}' > .gemini/context.json + env: + TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}' + DESCRIPTION: '${{ github.event.pull_request.body || github.event.issue.body }}' + EVENT_NAME: '${{ github.event_name }}' + IS_PULL_REQUEST: '${{ !!github.event.pull_request }}' + ISSUE_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}' + REPOSITORY: '${{ github.repository }}' + ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}' - name: 'Run Gemini CLI' id: 'run_gemini' uses: 'google-github-actions/run-gemini-cli@main' # ratchet:exclude env: + GEMINI_CLI_TRUST_WORKSPACE: 'true' TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}' DESCRIPTION: '${{ github.event.pull_request.body || github.event.issue.body }}' EVENT_NAME: '${{ github.event_name }}' @@ -66,6 +91,8 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-invoke' + github_pr_number: '${{ github.event.pull_request.number }}' + github_issue_number: '${{ github.event.issue.number }}' settings: |- { "model": { @@ -104,15 +131,6 @@ jobs: "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" } } - }, - "tools": { - "core": [ - "run_shell_command(cat)", - "run_shell_command(echo)", - "run_shell_command(grep)", - "run_shell_command(head)", - "run_shell_command(tail)" - ] } } prompt: '/gemini-invoke' diff --git a/.github/workflows/gemini-issue-fixer.yml b/.github/workflows/gemini-issue-fixer.yml index a19804418..704ff76c6 100644 --- a/.github/workflows/gemini-issue-fixer.yml +++ b/.github/workflows/gemini-issue-fixer.yml @@ -37,11 +37,36 @@ jobs: - name: 'Checkout repository' uses: 'actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8' # ratchet:actions/checkout@v6 + with: + persist-credentials: 'false' + + - name: 'Prepare prompt context' + shell: 'bash' + run: |- + mkdir -p .gemini + jq -n \ + --arg title "${TITLE}" \ + --arg body "${BODY}" \ + --arg repo "${REPOSITORY}" \ + --arg num "${NUMBER}" \ + --arg branch "${BRANCH}" \ + --arg event "${EVENT}" \ + --arg actor "${ACTOR}" \ + '{issue_title: $title, issue_body: $body, repository: $repo, issue_number: $num, branch_name: $branch, event_name: $event, triggering_actor: $actor}' > .gemini/context.json + env: + TITLE: '${{ github.event.issue.title }}' + BODY: '${{ github.event.issue.body }}' + REPOSITORY: '${{ github.repository }}' + NUMBER: '${{ github.event.issue.number }}' + BRANCH: 'gemini-fix-${{ github.event.issue.number }}' + EVENT: '${{ github.event_name }}' + ACTOR: '${{ github.triggering_actor }}' - name: 'Run Gemini PR Create' uses: 'google-github-actions/run-gemini-cli@main' # ratchet:exclude id: 'gemini_pr_create' env: + GEMINI_CLI_TRUST_WORKSPACE: 'true' GITHUB_TOKEN: '${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN }}' REPOSITORY: '${{ github.repository }}' ISSUE_NUMBER: '${{ github.event.issue.number }}' @@ -63,6 +88,7 @@ jobs: use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}' use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' + github_issue_number: '${{ github.event.issue.number }}' settings: |- { "debug": ${{ fromJSON(vars.GEMINI_DEBUG || vars.ACTIONS_STEP_DEBUG || false) }}, diff --git a/.github/workflows/gemini-plan-execute.yml b/.github/workflows/gemini-plan-execute.yml index 9dfe61a21..2a5b83ee5 100644 --- a/.github/workflows/gemini-plan-execute.yml +++ b/.github/workflows/gemini-plan-execute.yml @@ -41,11 +41,36 @@ jobs: - name: 'Checkout Code' uses: 'actions/checkout@v4' # ratchet:exclude + with: + persist-credentials: 'false' + + - name: 'Prepare prompt context' + shell: 'bash' + run: |- + mkdir -p .gemini + jq -n \ + --arg title "${TITLE}" \ + --arg desc "${DESCRIPTION}" \ + --arg event "${EVENT_NAME}" \ + --arg pr "${IS_PULL_REQUEST}" \ + --arg num "${ISSUE_NUMBER}" \ + --arg repo "${REPOSITORY}" \ + --arg context "${ADDITIONAL_CONTEXT}" \ + '{title: $title, description: $desc, event_name: $event, is_pull_request: $pr, issue_number: $num, repository: $repo, additional_context: $context}' > .gemini/context.json + env: + TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}' + DESCRIPTION: '${{ github.event.pull_request.body || github.event.issue.body }}' + EVENT_NAME: '${{ github.event_name }}' + IS_PULL_REQUEST: '${{ !!github.event.pull_request }}' + ISSUE_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}' + REPOSITORY: '${{ github.repository }}' + ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}' - name: 'Run Gemini CLI' id: 'run_gemini' uses: 'google-github-actions/run-gemini-cli@main' # ratchet:exclude env: + GEMINI_CLI_TRUST_WORKSPACE: 'true' TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}' DESCRIPTION: '${{ github.event.pull_request.body || github.event.issue.body }}' EVENT_NAME: '${{ github.event_name }}' @@ -68,6 +93,8 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-plan-execute' + github_pr_number: '${{ github.event.pull_request.number }}' + github_issue_number: '${{ github.event.issue.number }}' settings: |- { "model": { @@ -112,15 +139,6 @@ jobs: "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" } } - }, - "tools": { - "core": [ - "run_shell_command(cat)", - "run_shell_command(echo)", - "run_shell_command(grep)", - "run_shell_command(head)", - "run_shell_command(tail)" - ] } } prompt: '/gemini-plan-execute' diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index 510bfb74b..5617abf6c 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -40,11 +40,28 @@ jobs: - name: 'Checkout repository' uses: 'actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8' # ratchet:actions/checkout@v6 + with: + persist-credentials: 'false' + + - name: 'Prepare prompt context' + shell: 'bash' + run: |- + mkdir -p .gemini + jq -n \ + --arg repo "${REPOSITORY}" \ + --arg pr "${PULL_REQUEST_NUMBER}" \ + --arg context "${ADDITIONAL_CONTEXT}" \ + '{repository: $repo, pull_request_number: $pr, additional_context: $context}' > .gemini/context.json + env: + REPOSITORY: '${{ github.repository }}' + PULL_REQUEST_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}' + ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}' - name: 'Run Gemini pull request review' uses: 'google-github-actions/run-gemini-cli@main' # ratchet:exclude id: 'gemini_pr_review' env: + GEMINI_CLI_TRUST_WORKSPACE: 'true' GITHUB_TOKEN: '${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}' ISSUE_TITLE: '${{ github.event.pull_request.title || github.event.issue.title }}' ISSUE_BODY: '${{ github.event.pull_request.body || github.event.issue.body }}' @@ -66,6 +83,7 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-review' + github_pr_number: '${{ github.event.pull_request.number }}' settings: |- { "model": { @@ -96,15 +114,6 @@ jobs: "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" } } - }, - "tools": { - "core": [ - "run_shell_command(cat)", - "run_shell_command(echo)", - "run_shell_command(grep)", - "run_shell_command(head)", - "run_shell_command(tail)" - ] } } extensions: | diff --git a/.github/workflows/gemini-scheduled-triage.yml b/.github/workflows/gemini-scheduled-triage.yml index 8f6632db5..915f25088 100644 --- a/.github/workflows/gemini-scheduled-triage.yml +++ b/.github/workflows/gemini-scheduled-triage.yml @@ -82,15 +82,31 @@ jobs: echo '📝 Setting output for GitHub Actions...' echo "issues_to_triage=${ISSUES}" >> "${GITHUB_OUTPUT}" + ISSUE_NUMBERS="$(echo "${ISSUES}" | jq -r '.[].number | tostring' | paste -sd, -)" + echo "issue_numbers=${ISSUE_NUMBERS}" >> "${GITHUB_OUTPUT}" + ISSUE_COUNT="$(echo "${ISSUES}" | jq 'length')" echo "✅ Found ${ISSUE_COUNT} issue(s) to triage! 🎯" + - name: 'Prepare prompt context' + shell: 'bash' + run: |- + mkdir -p .gemini + jq -n \ + --arg labels "${AVAILABLE_LABELS}" \ + --arg issues "${ISSUES_TO_TRIAGE}" \ + '{available_labels: $labels, issues_to_triage: ($issues | fromjson)}' > .gemini/context.json + env: + AVAILABLE_LABELS: '${{ steps.get_labels.outputs.available_labels }}' + ISSUES_TO_TRIAGE: '${{ steps.find_issues.outputs.issues_to_triage }}' + - name: 'Run Gemini Issue Analysis' id: 'gemini_issue_analysis' if: |- ${{ steps.find_issues.outputs.issues_to_triage != '[]' }} uses: 'google-github-actions/run-gemini-cli@main' # ratchet:exclude env: + GEMINI_CLI_TRUST_WORKSPACE: 'true' GITHUB_TOKEN: '' # Do not pass any auth token here since this runs on untrusted inputs ISSUES_TO_TRIAGE: '${{ steps.find_issues.outputs.issues_to_triage }}' REPOSITORY: '${{ github.repository }}' @@ -109,6 +125,7 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-scheduled-triage' + github_issue_number: '${{ steps.find_issues.outputs.issue_numbers }}' settings: |- { "model": { @@ -118,13 +135,6 @@ jobs: "enabled": true, "target": "local", "outfile": ".gemini/telemetry.log" - }, - "tools": { - "core": [ - "run_shell_command(echo)", - "run_shell_command(jq)", - "run_shell_command(printenv)" - ] } } prompt: '/gemini-scheduled-triage' diff --git a/.github/workflows/gemini-triage.yml b/.github/workflows/gemini-triage.yml index 22b1413c2..1df503399 100644 --- a/.github/workflows/gemini-triage.yml +++ b/.github/workflows/gemini-triage.yml @@ -55,12 +55,27 @@ jobs: core.info(`Found ${labelNames.length} labels: ${labelNames.join(', ')}`); return labelNames; + - name: 'Prepare prompt context' + shell: 'bash' + run: |- + mkdir -p .gemini + jq -n \ + --arg labels "${AVAILABLE_LABELS}" \ + --arg title "${ISSUE_TITLE}" \ + --arg body "${ISSUE_BODY}" \ + '{available_labels: $labels, issue_title: $title, issue_body: $body}' > .gemini/context.json + env: + AVAILABLE_LABELS: '${{ steps.get_labels.outputs.available_labels }}' + ISSUE_TITLE: '${{ github.event.issue.title }}' + ISSUE_BODY: '${{ github.event.issue.body }}' + - name: 'Run Gemini issue analysis' id: 'gemini_analysis' if: |- ${{ steps.get_labels.outputs.available_labels != '' }} uses: 'google-github-actions/run-gemini-cli@main' # ratchet:exclude env: + GEMINI_CLI_TRUST_WORKSPACE: 'true' GITHUB_TOKEN: '' # Do NOT pass any auth tokens here since this runs on untrusted inputs ISSUE_TITLE: '${{ github.event.issue.title }}' ISSUE_BODY: '${{ github.event.issue.body }}' @@ -79,6 +94,7 @@ jobs: use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}' upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}' workflow_name: 'gemini-triage' + github_issue_number: '${{ github.event.issue.number }}' settings: |- { "model": { @@ -88,11 +104,6 @@ jobs: "enabled": true, "target": "local", "outfile": ".gemini/telemetry.log" - }, - "tools": { - "core": [ - "run_shell_command(echo)" - ] } } prompt: '/gemini-triage' From 3fb32a51de061e2c18c3f26bc5a291254f86f458 Mon Sep 17 00:00:00 2001 From: Emily Hedlund Date: Wed, 29 Apr 2026 13:05:24 -0400 Subject: [PATCH 2/2] add empty tools.core block to deny tool access --- .github/workflows/gemini-invoke.yml | 3 +++ .github/workflows/gemini-issue-fixer.yml | 3 +++ .github/workflows/gemini-plan-execute.yml | 3 +++ .github/workflows/gemini-review.yml | 3 +++ .github/workflows/gemini-scheduled-triage.yml | 3 +++ .github/workflows/gemini-triage.yml | 3 +++ examples/workflows/gemini-assistant/gemini-invoke.yml | 3 +++ examples/workflows/gemini-assistant/gemini-plan-execute.yml | 3 +++ examples/workflows/issue-triage/gemini-scheduled-triage.yml | 3 +++ examples/workflows/issue-triage/gemini-triage.yml | 3 +++ examples/workflows/pr-review/gemini-review.yml | 3 +++ 11 files changed, 33 insertions(+) diff --git a/.github/workflows/gemini-invoke.yml b/.github/workflows/gemini-invoke.yml index d404e375d..664901a5d 100644 --- a/.github/workflows/gemini-invoke.yml +++ b/.github/workflows/gemini-invoke.yml @@ -131,6 +131,9 @@ jobs: "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" } } + }, + "tools": { + "core": [] } } prompt: '/gemini-invoke' diff --git a/.github/workflows/gemini-issue-fixer.yml b/.github/workflows/gemini-issue-fixer.yml index 704ff76c6..7382bfd07 100644 --- a/.github/workflows/gemini-issue-fixer.yml +++ b/.github/workflows/gemini-issue-fixer.yml @@ -95,6 +95,9 @@ jobs: "model": { "maxSessionTurns": 200 }, + "tools": { + "core": [] + }, "mcpServers": { "github": { "command": "docker", diff --git a/.github/workflows/gemini-plan-execute.yml b/.github/workflows/gemini-plan-execute.yml index 2a5b83ee5..9c36202dd 100644 --- a/.github/workflows/gemini-plan-execute.yml +++ b/.github/workflows/gemini-plan-execute.yml @@ -139,6 +139,9 @@ jobs: "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" } } + }, + "tools": { + "core": [] } } prompt: '/gemini-plan-execute' diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index 5617abf6c..a46d1486c 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -114,6 +114,9 @@ jobs: "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" } } + }, + "tools": { + "core": [] } } extensions: | diff --git a/.github/workflows/gemini-scheduled-triage.yml b/.github/workflows/gemini-scheduled-triage.yml index 915f25088..a86ae9eb0 100644 --- a/.github/workflows/gemini-scheduled-triage.yml +++ b/.github/workflows/gemini-scheduled-triage.yml @@ -135,6 +135,9 @@ jobs: "enabled": true, "target": "local", "outfile": ".gemini/telemetry.log" + }, + "tools": { + "core": [] } } prompt: '/gemini-scheduled-triage' diff --git a/.github/workflows/gemini-triage.yml b/.github/workflows/gemini-triage.yml index 1df503399..a06c76edd 100644 --- a/.github/workflows/gemini-triage.yml +++ b/.github/workflows/gemini-triage.yml @@ -104,6 +104,9 @@ jobs: "enabled": true, "target": "local", "outfile": ".gemini/telemetry.log" + }, + "tools": { + "core": [] } } prompt: '/gemini-triage' diff --git a/examples/workflows/gemini-assistant/gemini-invoke.yml b/examples/workflows/gemini-assistant/gemini-invoke.yml index d7052adfd..628a5514b 100644 --- a/examples/workflows/gemini-assistant/gemini-invoke.yml +++ b/examples/workflows/gemini-assistant/gemini-invoke.yml @@ -126,6 +126,9 @@ jobs: "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" } } + }, + "tools": { + "core": [] } } prompt: '/gemini-invoke' diff --git a/examples/workflows/gemini-assistant/gemini-plan-execute.yml b/examples/workflows/gemini-assistant/gemini-plan-execute.yml index d14d1ef34..a071734d5 100644 --- a/examples/workflows/gemini-assistant/gemini-plan-execute.yml +++ b/examples/workflows/gemini-assistant/gemini-plan-execute.yml @@ -134,6 +134,9 @@ jobs: "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" } } + }, + "tools": { + "core": [] } } prompt: '/gemini-plan-execute' diff --git a/examples/workflows/issue-triage/gemini-scheduled-triage.yml b/examples/workflows/issue-triage/gemini-scheduled-triage.yml index c6b1a4f80..a07d40bc0 100644 --- a/examples/workflows/issue-triage/gemini-scheduled-triage.yml +++ b/examples/workflows/issue-triage/gemini-scheduled-triage.yml @@ -134,6 +134,9 @@ jobs: "enabled": true, "target": "local", "outfile": ".gemini/telemetry.log" + }, + "tools": { + "core": [] } } prompt: '/gemini-scheduled-triage' diff --git a/examples/workflows/issue-triage/gemini-triage.yml b/examples/workflows/issue-triage/gemini-triage.yml index 38df91184..9c6e25f76 100644 --- a/examples/workflows/issue-triage/gemini-triage.yml +++ b/examples/workflows/issue-triage/gemini-triage.yml @@ -102,6 +102,9 @@ jobs: "enabled": true, "target": "local", "outfile": ".gemini/telemetry.log" + }, + "tools": { + "core": [] } } prompt: '/gemini-triage' diff --git a/examples/workflows/pr-review/gemini-review.yml b/examples/workflows/pr-review/gemini-review.yml index 1ec5400a3..07f087544 100644 --- a/examples/workflows/pr-review/gemini-review.yml +++ b/examples/workflows/pr-review/gemini-review.yml @@ -110,6 +110,9 @@ jobs: "GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}" } } + }, + "tools": { + "core": [] } } extensions: |