Skip to content

Commit deab491

Browse files
authored
fix(ci): explicitly define secrets in reusable workflows (#961)
* fix(ci): explicitly define secrets in reusable workflows Resolves the "Unrecognized named-value: 'secrets'" validation error in GitHub Actions. Reusable workflows triggered via `workflow_call` must explicitly declare the secrets they expect to receive, even when `secrets: inherit` is used by the caller. Updates: - .github/workflows/gemini-triage.yml - .github/workflows/gemini-review.yml - .github/workflows/gemini-invoke.yml * fix(ci): remove quotes from 'inherit' in secrets * fix(ci): make secrets optional for Vertex AI support * feat(ci): add workflow_dispatch for manual testing * docs: add GitHub Agent workflow details to AGENTS.md and README
1 parent 9c68ea9 commit deab491

File tree

6 files changed

+221
-70
lines changed

6 files changed

+221
-70
lines changed

.github/workflows/gemini-dispatch.yml

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
11
name: '🔀 Gemini Dispatch'
22

33
on:
4+
workflow_dispatch:
5+
inputs:
6+
command:
7+
description: 'Command to run'
8+
required: true
9+
type: choice
10+
options:
11+
- review
12+
- triage
13+
- invoke
14+
issue_number:
15+
description: 'Issue or PR number to act on'
16+
required: true
17+
type: string
18+
additional_context:
19+
description: 'Additional context/prompt'
20+
required: false
21+
type: string
422
pull_request_review_comment:
523
types:
624
- 'created'
@@ -57,6 +75,8 @@ jobs:
5775
) || (
5876
github.event_name == 'issues' &&
5977
contains(fromJSON('["opened", "reopened"]'), github.event.action)
78+
) || (
79+
github.event_name == 'workflow_dispatch'
6080
)
6181
runs-on: 'ubuntu-latest'
6282
permissions:
@@ -67,7 +87,7 @@ jobs:
6787
command: '${{ steps.extract_command.outputs.command }}'
6888
request: '${{ steps.extract_command.outputs.request }}'
6989
additional_context: '${{ steps.extract_command.outputs.additional_context }}'
70-
issue_number: '${{ github.event.pull_request.number || github.event.issue.number }}'
90+
issue_number: '${{ github.event.pull_request.number || github.event.issue.number || inputs.issue_number }}'
7191
steps:
7292
- name: 'Mint identity token'
7393
id: 'mint_identity_token'
@@ -87,10 +107,22 @@ jobs:
87107
env:
88108
EVENT_TYPE: '${{ github.event_name }}.${{ github.event.action }}'
89109
REQUEST: '${{ github.event.comment.body || github.event.review.body || github.event.issue.body }}'
110+
INPUT_COMMAND: '${{ inputs.command }}'
111+
INPUT_CONTEXT: '${{ inputs.additional_context }}'
90112
with:
91113
script: |
92114
const request = process.env.REQUEST;
93-
const eventType = process.env.EVENT_TYPE
115+
const eventType = process.env.EVENT_TYPE;
116+
const inputCommand = process.env.INPUT_COMMAND;
117+
const inputContext = process.env.INPUT_CONTEXT;
118+
119+
if (inputCommand) {
120+
core.setOutput('command', inputCommand);
121+
core.setOutput('additional_context', inputContext || '');
122+
core.setOutput('request', `Manual dispatch: ${inputCommand}`);
123+
return;
124+
}
125+
94126
core.setOutput('request', request);
95127
96128
if (request.startsWith("@gemini-cli /review")) {
@@ -114,7 +146,7 @@ jobs:
114146
- name: 'Acknowledge request'
115147
env:
116148
GITHUB_TOKEN: '${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}'
117-
ISSUE_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
149+
ISSUE_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number || inputs.issue_number }}'
118150
MESSAGE: |-
119151
🤖 Hi @${{ github.actor }}, I've received your request, and I'm working on it now! You can track my progress [in the logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details.
120152
REPOSITORY: '${{ github.repository }}'
@@ -135,7 +167,7 @@ jobs:
135167
pull-requests: 'write'
136168
with:
137169
additional_context: '${{ needs.dispatch.outputs.additional_context }}'
138-
secrets: 'inherit'
170+
secrets: inherit
139171

140172
triage:
141173
needs: 'dispatch'
@@ -149,7 +181,7 @@ jobs:
149181
pull-requests: 'write'
150182
with:
151183
additional_context: '${{ needs.dispatch.outputs.additional_context }}'
152-
secrets: 'inherit'
184+
secrets: inherit
153185

154186
invoke:
155187
needs: 'dispatch'
@@ -163,7 +195,7 @@ jobs:
163195
pull-requests: 'write'
164196
with:
165197
additional_context: '${{ needs.dispatch.outputs.additional_context }}'
166-
secrets: 'inherit'
198+
secrets: inherit
167199

168200
fallthrough:
169201
needs:
@@ -194,7 +226,7 @@ jobs:
194226
- name: 'Send failure comment'
195227
env:
196228
GITHUB_TOKEN: '${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}'
197-
ISSUE_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
229+
ISSUE_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number || inputs.issue_number }}'
198230
MESSAGE: |-
199231
🤖 I'm sorry @${{ github.actor }}, but I was unable to process your request. Please [see the logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) for more details.
200232
REPOSITORY: '${{ github.repository }}'

.github/workflows/gemini-invoke.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ on:
77
type: 'string'
88
description: 'Any additional context from the request'
99
required: false
10+
secrets:
11+
GEMINI_API_KEY:
12+
required: false
13+
GOOGLE_API_KEY:
14+
required: false
15+
APP_PRIVATE_KEY:
16+
required: false
1017

1118
concurrency:
1219
group: '${{ github.workflow }}-invoke-${{ github.event_name }}-${{ github.event.pull_request.number || github.event.issue.number }}'

.github/workflows/gemini-review.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ on:
77
type: 'string'
88
description: 'Any additional context from the request'
99
required: false
10+
secrets:
11+
GEMINI_API_KEY:
12+
required: false
13+
GOOGLE_API_KEY:
14+
required: false
15+
APP_PRIVATE_KEY:
16+
required: false
1017

1118
concurrency:
1219
group: '${{ github.workflow }}-review-${{ github.event_name }}-${{ github.event.pull_request.number || github.event.issue.number }}'

.github/workflows/gemini-triage.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ on:
77
type: 'string'
88
description: 'Any additional context from the request'
99
required: false
10+
secrets:
11+
GEMINI_API_KEY:
12+
required: false
13+
GOOGLE_API_KEY:
14+
required: false
15+
APP_PRIVATE_KEY:
16+
required: false
1017

1118
concurrency:
1219
group: '${{ github.workflow }}-triage-${{ github.event_name }}-${{ github.event.pull_request.number || github.event.issue.number }}'

AGENTS.md

Lines changed: 69 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,43 +3,106 @@
33
This document provides guidelines for AI agents working on the GenMedia Creative Studio codebase.
44

55
## Styling
6+
67
- Prefer using shared styles from `components/styles.py` for common UI elements and layout structures.
78
- Page-specific or component-specific styles that are not reusable can be defined locally within those files.
89

910
## Google Cloud Storage (GCS)
11+
1012
- All interactions with GCS for storing media or other assets should use the `store_to_gcs` utility function located in `common/storage.py`.
1113
- This function is configurable via `config/default.py` for bucket names.
1214

1315
## Configuration
16+
1417
- Application-level configuration values, such as model IDs, API keys (though avoid hardcoding keys directly), GCS bucket names, and feature flags, should be defined in `config/default.py`.
1518
- Access these configurations by importing `cfg = Default()` from `config.default`.
1619

1720
## State Management
21+
1822
- Global application state (e.g., theme, user information) is managed in `state/state.py`.
1923
- Page-specific UI state should be defined in corresponding files within the `state/` directory (e.g., `state/imagen_state.py`, `state/veo_state.py`).
2024

2125
## Error Handling
26+
2227
- For errors that occur during media generation processes and need to be communicated to the user, use the `GenerationError` custom exception defined in `common/error_handling.py`.
2328
- Display these errors to the user via dialogs or appropriate UI elements.
2429
- Log detailed errors to the console/server logs for debugging.
2530

2631
## Adding New Generative Models
32+
2733
- When adding a new generative model capability (e.g., a new type of image model, a different video model):
28-
- Add model interaction logic (API calls, request/response handling) to a new file in the `models/` directory (e.g., `models/new_model_name.py`).
29-
- Create UI components for controlling the new model in a subdirectory under `components/` (e.g., `components/new_model_name/generation_controls.py`).
30-
- Create a new page for the model in `pages/` (e.g., `pages/new_model_name.py`), utilizing the page scaffold and new components.
31-
- Define any page-specific state in `state/new_model_name_state.py`.
32-
- Add relevant configurations to `config/default.py`.
33-
- Update navigation in `config/navigation.json`.
34+
- Add model interaction logic (API calls, request/response handling) to a new file in the `models/` directory (e.g., `models/new_model_name.py`).
35+
- Create UI components for controlling the new model in a subdirectory under `components/` (e.g., `components/new_model_name/generation_controls.py`).
36+
- Create a new page for the model in `pages/` (e.g., `pages/new_model_name.py`), utilizing the page scaffold and new components.
37+
- Define any page-specific state in `state/new_model_name_state.py`.
38+
- Add relevant configurations to `config/default.py`.
39+
- Update navigation in `config/navigation.json`.
3440

3541
## Metadata
42+
3643
- When storing metadata for generated media, use the `MediaItem` dataclass from `common/metadata.py` and the `add_media_item_to_firestore` function.
3744
- Ensure all relevant fields in `MediaItem` are populated.
3845

3946
## Testing
47+
4048
- Write unit tests for utility functions and model interaction logic.
4149
- Aim to mock external API calls during unit testing.
4250
- Use `pytest` as the testing framework.
4351

4452
## Code Quality
53+
4554
- Use `ruff` for code formatting and linting. Ensure code is formatted (`ruff format .`) and linted (`ruff check --fix .`) before submitting changes.
55+
56+
57+
## 🤖 GitHub Automation Agents
58+
59+
This repository uses **Google's Gemini CLI** to automate software engineering tasks. Our AI agents assist with code reviews, issue triage, and general maintenance to keep the project moving efficiently.
60+
61+
## Automatic Behaviors
62+
63+
These agents run automatically based on events in the repository.
64+
65+
### 🔎 Code Reviewer
66+
67+
- **Trigger:** When a **Pull Request** is opened.
68+
69+
- **Action:** The agent reviews the code changes (diff), looking for bugs, security issues, and style improvements.
70+
- **Output:** It posts review comments directly on the PR.
71+
- **Note:** The agent focuses on the *diff* only and provides constructive feedback. It does not replace human review.
72+
73+
### 📋 Issue Triage
74+
75+
- **Trigger:** When a new **Issue** is opened.
76+
77+
- **Action:** The agent analyzes the title and body of the issue.
78+
- **Output:** It automatically applies relevant **Labels** (e.g., `bug`, `enhancement`, `question`) to help organize the backlog.
79+
80+
---
81+
82+
## Maintainer Commands
83+
84+
Project maintainers (Owners, Members, Collaborators) can manually invoke the agents using comment commands.
85+
86+
| Command | Description |
87+
| :--- | :--- |
88+
| `@gemini-cli /review` | Manually triggers a full code review on the current Pull Request. |
89+
| `@gemini-cli /triage` | Manually triggers label analysis on the current Issue or PR. |
90+
| `@gemini-cli [question]` | Ask the agent a question about the codebase or request a specific task.
91+
92+
*Example:* `@gemini-cli Explain how the authentication flow works.` |
93+
94+
> **Note:** These commands are restricted to project maintainers to prevent abuse and manage costs.
95+
96+
---
97+
98+
## Workflow Architecture
99+
100+
The automation is built on GitHub Actions using a "Router-Worker" pattern:
101+
102+
1. **Dispatch Router (`gemini-dispatch.yml`):** The entry point. It listens for events, validates permissions, and routes the request to the correct worker.
103+
2. **Worker Workflows:**
104+
- `gemini-review.yml`: Handles code analysis.
105+
- `gemini-triage.yml`: Handles labeling.
106+
- `gemini-invoke.yml`: Handles general Q&A.
107+
108+
This system is powered by the [Gemini CLI](https://github.com/google-github-actions/run-gemini-cli) action.

0 commit comments

Comments
 (0)