Skip to content

Commit bf94bec

Browse files
committed
fix: add auth checks and trust workspace in gemini workflows
1 parent 8b96a6d commit bf94bec

5 files changed

Lines changed: 40 additions & 0 deletions

File tree

.github/workflows/gemini-invoke.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ jobs:
4040
- name: 'Checkout Code'
4141
uses: 'actions/checkout@v4' # ratchet:exclude
4242

43+
- name: 'Check for Gemini Authentication'
44+
run: |
45+
if [[ -z "${{ secrets.GEMINI_API_KEY }}" && -z "${{ secrets.GOOGLE_API_KEY }}" && -z "${{ vars.GCP_WIF_PROVIDER }}" ]]; then
46+
echo "::error::Gemini API authentication is not configured. Please add GEMINI_API_KEY or GOOGLE_API_KEY to your repository secrets, or configure Google Cloud Workload Identity Federation."
47+
exit 1
48+
fi
49+
4350
- name: 'Run Gemini CLI'
4451
id: 'run_gemini'
4552
uses: 'google-github-actions/run-gemini-cli@v0' # ratchet:exclude
@@ -52,6 +59,7 @@ jobs:
5259
ISSUE_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
5360
REPOSITORY: '${{ github.repository }}'
5461
ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}'
62+
GEMINI_CLI_TRUST_WORKSPACE: 'true'
5563
with:
5664
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
5765
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'

.github/workflows/gemini-plan-execute.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,13 @@ jobs:
4242
- name: 'Checkout Code'
4343
uses: 'actions/checkout@v4' # ratchet:exclude
4444

45+
- name: 'Check for Gemini Authentication'
46+
run: |
47+
if [[ -z "${{ secrets.GEMINI_API_KEY }}" && -z "${{ secrets.GOOGLE_API_KEY }}" && -z "${{ vars.GCP_WIF_PROVIDER }}" ]]; then
48+
echo "::error::Gemini API authentication is not configured. Please add GEMINI_API_KEY or GOOGLE_API_KEY to your repository secrets, or configure Google Cloud Workload Identity Federation."
49+
exit 1
50+
fi
51+
4552
- name: 'Run Gemini CLI'
4653
id: 'run_gemini'
4754
uses: 'google-github-actions/run-gemini-cli@v0' # ratchet:exclude
@@ -54,6 +61,7 @@ jobs:
5461
ISSUE_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
5562
REPOSITORY: '${{ github.repository }}'
5663
ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}'
64+
GEMINI_CLI_TRUST_WORKSPACE: 'true'
5765
with:
5866
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
5967
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'

.github/workflows/gemini-review.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ jobs:
4141
- name: 'Checkout repository'
4242
uses: 'actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8' # ratchet:actions/checkout@v6
4343

44+
- name: 'Check for Gemini Authentication'
45+
run: |
46+
if [[ -z "${{ secrets.GEMINI_API_KEY }}" && -z "${{ secrets.GOOGLE_API_KEY }}" && -z "${{ vars.GCP_WIF_PROVIDER }}" ]]; then
47+
echo "::error::Gemini API authentication is not configured. Please add GEMINI_API_KEY or GOOGLE_API_KEY to your repository secrets, or configure Google Cloud Workload Identity Federation."
48+
exit 1
49+
fi
50+
4451
- name: 'Run Gemini pull request review'
4552
uses: 'google-github-actions/run-gemini-cli@v0' # ratchet:exclude
4653
id: 'gemini_pr_review'
@@ -52,6 +59,7 @@ jobs:
5259
REPOSITORY: '${{ github.repository }}'
5360
ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}'
5461
GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}'
62+
GEMINI_CLI_TRUST_WORKSPACE: 'true'
5563
with:
5664
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
5765
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'

.github/workflows/gemini-scheduled-triage.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ jobs:
8888
ISSUE_COUNT="$(echo "${ISSUES}" | jq 'length')"
8989
echo "✅ Found ${ISSUE_COUNT} issue(s) to triage! 🎯"
9090
91+
- name: 'Check for Gemini Authentication'
92+
run: |
93+
if [[ -z "${{ secrets.GEMINI_API_KEY }}" && -z "${{ secrets.GOOGLE_API_KEY }}" && -z "${{ vars.GCP_WIF_PROVIDER }}" ]]; then
94+
echo "::error::Gemini API authentication is not configured. Please add GEMINI_API_KEY or GOOGLE_API_KEY to your repository secrets, or configure Google Cloud Workload Identity Federation."
95+
exit 1
96+
fi
97+
9198
- name: 'Run Gemini Issue Analysis'
9299
id: 'gemini_issue_analysis'
93100
if: |-
@@ -98,6 +105,7 @@ jobs:
98105
ISSUES_TO_TRIAGE: '${{ steps.find_issues.outputs.issues_to_triage }}'
99106
REPOSITORY: '${{ github.repository }}'
100107
AVAILABLE_LABELS: '${{ steps.get_labels.outputs.available_labels }}'
108+
GEMINI_CLI_TRUST_WORKSPACE: 'true'
101109
with:
102110
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
103111
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'

.github/workflows/gemini-triage.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,13 @@ jobs:
5555
core.info(`Found ${labelNames.length} labels: ${labelNames.join(', ')}`);
5656
return labelNames;
5757
58+
- name: 'Check for Gemini Authentication'
59+
run: |
60+
if [[ -z "${{ secrets.GEMINI_API_KEY }}" && -z "${{ secrets.GOOGLE_API_KEY }}" && -z "${{ vars.GCP_WIF_PROVIDER }}" ]]; then
61+
echo "::error::Gemini API authentication is not configured. Please add GEMINI_API_KEY or GOOGLE_API_KEY to your repository secrets, or configure Google Cloud Workload Identity Federation."
62+
exit 1
63+
fi
64+
5865
- name: 'Run Gemini issue analysis'
5966
id: 'gemini_analysis'
6067
if: |-
@@ -65,6 +72,7 @@ jobs:
6572
ISSUE_TITLE: '${{ github.event.issue.title }}'
6673
ISSUE_BODY: '${{ github.event.issue.body }}'
6774
AVAILABLE_LABELS: '${{ steps.get_labels.outputs.available_labels }}'
75+
GEMINI_CLI_TRUST_WORKSPACE: 'true'
6876
with:
6977
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
7078
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'

0 commit comments

Comments
 (0)