Skip to content

Commit 273c5d3

Browse files
authored
refactor(workflows): improve prompts to use env vars directly (#342)
The prompts in the workflows are updated to directly embed environment variables using `${{ env.VAR }}` syntax. This makes the prompts clearer and avoids instructing the model to use `echo` to retrieve values, simplifying the instructions. This should also improve quality of response. cc @anj-s
1 parent b097d2c commit 273c5d3

File tree

9 files changed

+118
-75
lines changed

9 files changed

+118
-75
lines changed

.github/workflows/gemini-invoke.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,14 @@ jobs:
161161
162162
Begin every task by building a complete picture of the situation.
163163
164-
1. **Load Initial Variables**: Load `${TITLE}`, `${DESCRIPTION}`, `${EVENT_NAME}`, etc.
164+
1. **Initial Context**:
165+
- **Title**: ${{ env.TITLE }}
166+
- **Description**: ${{ env.DESCRIPTION }}
167+
- **Event Name**: ${{ env.EVENT_NAME }}
168+
- **Is Pull Request**: ${{ env.IS_PULL_REQUEST }}
169+
- **Issue/PR Number**: ${{ env.ISSUE_NUMBER }}
170+
- **Repository**: ${{ env.REPOSITORY }}
171+
- **Additional Context/Request**: ${{ env.ADDITIONAL_CONTEXT }}
165172
166173
2. **Deepen Context with Tools**: Use `mcp__github__get_issue`, `mcp__github__get_pull_request_diff`, and `mcp__github__get_file_contents` to investigate the request thoroughly.
167174

.github/workflows/gemini-issue-fixer.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,14 @@ jobs:
102102
<issue>
103103
<repository>${{ env.REPOSITORY }}</repository>
104104
<number>${{ env.ISSUE_NUMBER }}</number>
105-
<title>The title exists in the ISSUE_TITLE environment variable. Run `echo $ISSUE_TITLE` to fetch it.</title>
106-
<body>The title exists in the ISSUE_BODY environment variable. Run `echo $ISSUE_BODY` to fetch it.</body>
105+
<title>${{ env.ISSUE_TITLE }}</title>
106+
<body>${{ env.ISSUE_BODY }}</body>
107107
</issue>
108108
</github_event>
109109
</context>
110110
<instructions>
111111
<description>Follow these steps sequentially to resolve the issue.</description>
112112
<steps>
113-
<step id="0" name="Get Issue Title and Issue Body">
114-
The issue's title and body are stored in the ISSUE_TITLE and ISSUE_BODY environment variables. Read them with `echo $ISSUE_TITLE` and `echo $ISSUE_BODY`.
115-
</step>
116113
<step id="1" name="Understand Project Standards">
117114
The initial context provided to you includes a file tree. If you see a `GEMINI.md` or `CONTRIBUTING.md` file, use the GitHub MCP `get_file_contents` tool to read it first. This file may contain critical project-specific instructions, such as commands for building, testing, or linting.
118115
</step>

.github/workflows/gemini-review.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ jobs:
138138
139139
## Input Data
140140
141-
- Retrieve the GitHub repository name from the environment variable "${REPOSITORY}".
142-
- Retrieve the GitHub pull request number from the environment variable "${PULL_REQUEST_NUMBER}".
143-
- Retrieve the additional user instructions and context from the environment variable "${ADDITIONAL_CONTEXT}".
141+
- **GitHub Repository**: ${{ env.REPOSITORY }}
142+
- **Pull Request Number**: ${{ env.PULL_REQUEST_NUMBER }}
143+
- **Additional User Instructions**: ${{ env.ADDITIONAL_CONTEXT }}
144144
- Use `mcp__github__get_pull_request` to get the title, body, and metadata about the pull request.
145145
- Use `mcp__github__get_pull_request_files` to get the list of files that were added, removed, and changed in the pull request.
146146
- Use `mcp__github__get_pull_request_diff` to get the diff from the pull request. The diff includes code versions with line numbers for the before (LEFT) and after (RIGHT) code snippets for each diff.

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

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -143,33 +143,37 @@ jobs:
143143
144144
5. **Command Substitution**: When generating shell commands, you **MUST NOT** use command substitution with `$(...)`, `<(...)`, or `>(...)`. This is a security measure to prevent unintended command execution.
145145
146-
## Input Data Description
146+
## Input Data
147147
148-
You will work with the following environment variables:
148+
The following data is provided for your analysis:
149149
150-
- **`AVAILABLE_LABELS`**: Contains a single, comma-separated string of all available label names (e.g., `"kind/bug,priority/p1,docs"`).
150+
**Available Labels** (single, comma-separated string of all available label names):
151+
```
152+
${{ env.AVAILABLE_LABELS }}
153+
```
151154
152-
- **`ISSUES_TO_TRIAGE`**: Contains a string of a JSON array, where each object has `"number"`, `"title"`, and `"body"` keys.
155+
**Issues to Triage** (JSON array where each object has `"number"`, `"title"`, and `"body"` keys):
156+
```
157+
${{ env.ISSUES_TO_TRIAGE }}
158+
```
153159
154-
- **`GITHUB_ENV`**: Contains the file path where your final JSON output must be written.
160+
**Output File Path** where your final JSON output must be written:
161+
```
162+
${{ env.GITHUB_ENV }}
163+
```
155164
156165
## Execution Workflow
157166
158-
Follow this five-step process sequentially.
159-
160-
## Step 1: Retrieve Input Data
161-
162-
First, retrieve all necessary information from the environment by executing the following shell commands. You will use the resulting shell variables in the subsequent steps.
163-
164-
1. `Run: LABELS_DATA=$(echo "${AVAILABLE_LABELS}")`
165-
2. `Run: ISSUES_DATA=$(echo "${ISSUES_TO_TRIAGE}")`
166-
3. `Run: OUTPUT_PATH=$(echo "${GITHUB_ENV}")`
167+
Follow this four-step process sequentially:
167168
168-
## Step 2: Parse Inputs
169+
## Step 1: Parse Input Data
169170
170-
Parse the content of the `LABELS_DATA` shell variable into a list of strings. Parse the content of the `ISSUES_DATA` shell variable into a JSON array of issue objects.
171+
Parse the provided data above:
172+
- Split the available labels by comma to get the list of valid labels
173+
- Parse the JSON array of issues to analyze
174+
- Note the output file path where you will write your results
171175
172-
## Step 3: Analyze Label Semantics
176+
## Step 2: Analyze Label Semantics
173177
174178
Before reviewing the issues, create an internal map of the semantic purpose of each available label based on its name. For example:
175179
@@ -183,7 +187,7 @@ jobs:
183187
184188
This semantic map will serve as your classification criteria.
185189
186-
## Step 4: Triage Issues
190+
## Step 3: Triage Issues
187191
188192
Iterate through each issue object you parsed in Step 2. For each issue:
189193
@@ -195,11 +199,11 @@ jobs:
195199
196200
4. If no available labels are a clear and confident match for an issue, exclude that issue from the final output.
197201
198-
## Step 5: Construct and Write Output
202+
## Step 4: Construct and Write Output
199203
200204
Assemble the results into a single JSON array, formatted as a string, according to the **Output Specification** below. Finally, execute the command to write this string to the output file, ensuring the JSON is enclosed in single quotes to prevent shell interpretation.
201205
202-
- `Run: echo 'TRIAGED_ISSUES=...' > "${OUTPUT_PATH}"`. (Replace `...` with the final, minified JSON array string).
206+
- Use the shell command to write: `echo 'TRIAGED_ISSUES=...' > "$GITHUB_ENV"` (Replace `...` with the final, minified JSON array string).
203207
204208
## Output Specification
205209

.github/workflows/gemini-triage.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,29 +97,41 @@ jobs:
9797
9898
## Guidelines
9999
100-
- Retrieve the value for environment variables using the "echo" shell command.
101-
- Environment variables are specified in the format "${VARIABLE}" (with quotes and braces).
102100
- Only use labels that are from the list of available labels.
103101
- You can choose multiple labels to apply.
104102
- When generating shell commands, you **MUST NOT** use command substitution with `$(...)`, `<(...)`, or `>(...)`. This is a security measure to prevent unintended command execution.
105103
106-
## Steps
104+
## Input Data
105+
106+
**Available Labels** (comma-separated):
107+
```
108+
${{ env.AVAILABLE_LABELS }}
109+
```
107110
108-
1. Retrieve the available labels from the environment variable: "${AVAILABLE_LABELS}".
111+
**Issue Title**:
112+
```
113+
${{ env.ISSUE_TITLE }}
114+
```
109115
110-
2. Retrieve the issue title from the environment variable: "${ISSUE_TITLE}".
116+
**Issue Body**:
117+
```
118+
${{ env.ISSUE_BODY }}
119+
```
111120
112-
3. Retrieve the issue body from the environment variable: "${ISSUE_BODY}".
121+
**Output File Path**:
122+
```
123+
${{ env.GITHUB_ENV }}
124+
```
113125
114-
4. Review the issue title, issue body, and available labels.
126+
## Steps
115127
116-
5. Based on the issue title and issue body, classify the issue and choose all appropriate labels from the list of available labels.
128+
1. Review the issue title, issue body, and available labels provided above.
117129
118-
6. Classify the issue by identifying the appropriate labels from the list of available labels.
130+
2. Based on the issue title and issue body, classify the issue and choose all appropriate labels from the list of available labels.
119131
120-
7. Convert the list of appropriate labels into a comma-separated list (CSV). If there are no appropriate labels, use the empty string.
132+
3. Convert the list of appropriate labels into a comma-separated list (CSV). If there are no appropriate labels, use the empty string.
121133
122-
8. Use the "echo" shell command to append the CSV labels into the filepath referenced by the environment variable "${GITHUB_ENV}":
134+
4. Use the "echo" shell command to append the CSV labels to the output file path provided above:
123135
124136
```
125137
echo "SELECTED_LABELS=[APPROPRIATE_LABELS_AS_CSV]" >> "[filepath_for_env]"

examples/workflows/gemini-assistant/gemini-invoke.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,14 @@ jobs:
161161
162162
Begin every task by building a complete picture of the situation.
163163
164-
1. **Load Initial Variables**: Load `${TITLE}`, `${DESCRIPTION}`, `${EVENT_NAME}`, etc.
164+
1. **Initial Context**:
165+
- **Title**: ${{ env.TITLE }}
166+
- **Description**: ${{ env.DESCRIPTION }}
167+
- **Event Name**: ${{ env.EVENT_NAME }}
168+
- **Is Pull Request**: ${{ env.IS_PULL_REQUEST }}
169+
- **Issue/PR Number**: ${{ env.ISSUE_NUMBER }}
170+
- **Repository**: ${{ env.REPOSITORY }}
171+
- **Additional Context/Request**: ${{ env.ADDITIONAL_CONTEXT }}
165172
166173
2. **Deepen Context with Tools**: Use `mcp__github__get_issue`, `mcp__github__get_pull_request_diff`, and `mcp__github__get_file_contents` to investigate the request thoroughly.
167174

examples/workflows/issue-triage/gemini-scheduled-triage.yml

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -143,33 +143,37 @@ jobs:
143143
144144
5. **Command Substitution**: When generating shell commands, you **MUST NOT** use command substitution with `$(...)`, `<(...)`, or `>(...)`. This is a security measure to prevent unintended command execution.
145145
146-
## Input Data Description
146+
## Input Data
147147
148-
You will work with the following environment variables:
148+
The following data is provided for your analysis:
149149
150-
- **`AVAILABLE_LABELS`**: Contains a single, comma-separated string of all available label names (e.g., `"kind/bug,priority/p1,docs"`).
150+
**Available Labels** (single, comma-separated string of all available label names):
151+
```
152+
${{ env.AVAILABLE_LABELS }}
153+
```
151154
152-
- **`ISSUES_TO_TRIAGE`**: Contains a string of a JSON array, where each object has `"number"`, `"title"`, and `"body"` keys.
155+
**Issues to Triage** (JSON array where each object has `"number"`, `"title"`, and `"body"` keys):
156+
```
157+
${{ env.ISSUES_TO_TRIAGE }}
158+
```
153159
154-
- **`GITHUB_ENV`**: Contains the file path where your final JSON output must be written.
160+
**Output File Path** where your final JSON output must be written:
161+
```
162+
${{ env.GITHUB_ENV }}
163+
```
155164
156165
## Execution Workflow
157166
158-
Follow this five-step process sequentially.
159-
160-
## Step 1: Retrieve Input Data
161-
162-
First, retrieve all necessary information from the environment by executing the following shell commands. You will use the resulting shell variables in the subsequent steps.
163-
164-
1. `Run: LABELS_DATA=$(echo "${AVAILABLE_LABELS}")`
165-
2. `Run: ISSUES_DATA=$(echo "${ISSUES_TO_TRIAGE}")`
166-
3. `Run: OUTPUT_PATH=$(echo "${GITHUB_ENV}")`
167+
Follow this four-step process sequentially:
167168
168-
## Step 2: Parse Inputs
169+
## Step 1: Parse Input Data
169170
170-
Parse the content of the `LABELS_DATA` shell variable into a list of strings. Parse the content of the `ISSUES_DATA` shell variable into a JSON array of issue objects.
171+
Parse the provided data above:
172+
- Split the available labels by comma to get the list of valid labels
173+
- Parse the JSON array of issues to analyze
174+
- Note the output file path where you will write your results
171175
172-
## Step 3: Analyze Label Semantics
176+
## Step 2: Analyze Label Semantics
173177
174178
Before reviewing the issues, create an internal map of the semantic purpose of each available label based on its name. For example:
175179
@@ -183,7 +187,7 @@ jobs:
183187
184188
This semantic map will serve as your classification criteria.
185189
186-
## Step 4: Triage Issues
190+
## Step 3: Triage Issues
187191
188192
Iterate through each issue object you parsed in Step 2. For each issue:
189193
@@ -195,11 +199,11 @@ jobs:
195199
196200
4. If no available labels are a clear and confident match for an issue, exclude that issue from the final output.
197201
198-
## Step 5: Construct and Write Output
202+
## Step 4: Construct and Write Output
199203
200204
Assemble the results into a single JSON array, formatted as a string, according to the **Output Specification** below. Finally, execute the command to write this string to the output file, ensuring the JSON is enclosed in single quotes to prevent shell interpretation.
201205
202-
- `Run: echo 'TRIAGED_ISSUES=...' > "${OUTPUT_PATH}"`. (Replace `...` with the final, minified JSON array string).
206+
- Use the shell command to write: `echo 'TRIAGED_ISSUES=...' > "$GITHUB_ENV"` (Replace `...` with the final, minified JSON array string).
203207
204208
## Output Specification
205209

examples/workflows/issue-triage/gemini-triage.yml

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -97,29 +97,41 @@ jobs:
9797
9898
## Guidelines
9999
100-
- Retrieve the value for environment variables using the "echo" shell command.
101-
- Environment variables are specified in the format "${VARIABLE}" (with quotes and braces).
102100
- Only use labels that are from the list of available labels.
103101
- You can choose multiple labels to apply.
104102
- When generating shell commands, you **MUST NOT** use command substitution with `$(...)`, `<(...)`, or `>(...)`. This is a security measure to prevent unintended command execution.
105103
106-
## Steps
104+
## Input Data
105+
106+
**Available Labels** (comma-separated):
107+
```
108+
${{ env.AVAILABLE_LABELS }}
109+
```
107110
108-
1. Retrieve the available labels from the environment variable: "${AVAILABLE_LABELS}".
111+
**Issue Title**:
112+
```
113+
${{ env.ISSUE_TITLE }}
114+
```
109115
110-
2. Retrieve the issue title from the environment variable: "${ISSUE_TITLE}".
116+
**Issue Body**:
117+
```
118+
${{ env.ISSUE_BODY }}
119+
```
111120
112-
3. Retrieve the issue body from the environment variable: "${ISSUE_BODY}".
121+
**Output File Path**:
122+
```
123+
${{ env.GITHUB_ENV }}
124+
```
113125
114-
4. Review the issue title, issue body, and available labels.
126+
## Steps
115127
116-
5. Based on the issue title and issue body, classify the issue and choose all appropriate labels from the list of available labels.
128+
1. Review the issue title, issue body, and available labels provided above.
117129
118-
6. Classify the issue by identifying the appropriate labels from the list of available labels.
130+
2. Based on the issue title and issue body, classify the issue and choose all appropriate labels from the list of available labels.
119131
120-
7. Convert the list of appropriate labels into a comma-separated list (CSV). If there are no appropriate labels, use the empty string.
132+
3. Convert the list of appropriate labels into a comma-separated list (CSV). If there are no appropriate labels, use the empty string.
121133
122-
8. Use the "echo" shell command to append the CSV labels into the filepath referenced by the environment variable "${GITHUB_ENV}":
134+
4. Use the "echo" shell command to append the CSV labels to the output file path provided above:
123135
124136
```
125137
echo "SELECTED_LABELS=[APPROPRIATE_LABELS_AS_CSV]" >> "[filepath_for_env]"

examples/workflows/pr-review/gemini-review.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ jobs:
138138
139139
## Input Data
140140
141-
- Retrieve the GitHub repository name from the environment variable "${REPOSITORY}".
142-
- Retrieve the GitHub pull request number from the environment variable "${PULL_REQUEST_NUMBER}".
143-
- Retrieve the additional user instructions and context from the environment variable "${ADDITIONAL_CONTEXT}".
141+
- **GitHub Repository**: ${{ env.REPOSITORY }}
142+
- **Pull Request Number**: ${{ env.PULL_REQUEST_NUMBER }}
143+
- **Additional User Instructions**: ${{ env.ADDITIONAL_CONTEXT }}
144144
- Use `mcp__github__get_pull_request` to get the title, body, and metadata about the pull request.
145145
- Use `mcp__github__get_pull_request_files` to get the list of files that were added, removed, and changed in the pull request.
146146
- Use `mcp__github__get_pull_request_diff` to get the diff from the pull request. The diff includes code versions with line numbers for the before (LEFT) and after (RIGHT) code snippets for each diff.

0 commit comments

Comments
 (0)