Skip to content

Commit b5508bc

Browse files
authored
feat(telemetry): set GHA_NAME dynamically from workflow (#390)
Sets the GHA_NAME environment variable for the Gemini CLI action to the name of the executing workflow. This makes the telemetry data more accurate and easier to filter. A new step is added to sanitize the workflow name by removing emojis and leading/trailing whitespace, ensuring the GHA_NAME is a clean string.
1 parent 57ee480 commit b5508bc

File tree

10 files changed

+24
-0
lines changed

10 files changed

+24
-0
lines changed

.github/workflows/gemini-invoke.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
6363
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
6464
upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}'
65+
workflow_name: 'gemini-invoke'
6566
settings: |-
6667
{
6768
"model": {

.github/workflows/gemini-review.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ jobs:
6464
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
6565
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
6666
upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}'
67+
workflow_name: 'gemini-review'
6768
settings: |-
6869
{
6970
"model": {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ jobs:
108108
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
109109
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
110110
upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}'
111+
workflow_name: 'gemini-scheduled-triage'
111112
settings: |-
112113
{
113114
"model": {

.github/workflows/gemini-triage.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
7979
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
8080
upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}'
81+
workflow_name: 'gemini-triage'
8182
settings: |-
8283
{
8384
"model": {

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ go to the [Gemini Assistant workflow documentation](./examples/workflows/gemini-
191191

192192
- <a name="__input_use_pnpm"></a><a href="#user-content-__input_use_pnpm"><code>use_pnpm</code></a>: _(Optional, default: `false`)_ Whether or not to use pnpm instead of npm to install gemini-cli
193193

194+
- <a name="__input_workflow_name"></a><a href="#user-content-__input_workflow_name"><code>workflow_name</code></a>: _(Optional, default: `${{ github.workflow }}`)_ The GitHub workflow name, used for telemetry purposes.
195+
194196

195197
<!-- END_AUTOGEN_INPUTS -->
196198

action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ inputs:
8787
description: 'Whether or not to use pnpm instead of npm to install gemini-cli'
8888
required: false
8989
default: 'false'
90+
workflow_name:
91+
description: 'The GitHub workflow name, used for telemetry purposes.'
92+
required: false
93+
default: '${{ github.workflow }}'
9094

9195
outputs:
9296
summary:
@@ -174,6 +178,15 @@ runs:
174178
INPUT_USE_VERTEX_AI: '${{ inputs.use_vertex_ai }}'
175179
INPUT_USE_GEMINI_CODE_ASSIST: '${{ inputs.use_gemini_code_assist }}'
176180

181+
- name: 'Sanitize workflow name'
182+
id: 'sanitize_workflow_name'
183+
shell: 'bash'
184+
run: |
185+
SANITIZED=$(echo "${WORKFLOW_NAME}" | sed 's/[^ a-zA-Z0-9-]//g' | xargs | tr ' ' '_' | tr '[:upper:]' '[:lower:]')
186+
echo "gh_workflow_name=$SANITIZED" >> $GITHUB_OUTPUT
187+
env:
188+
WORKFLOW_NAME: '${{ inputs.workflow_name }}'
189+
177190
- name: 'Configure Gemini CLI'
178191
if: |-
179192
${{ inputs.settings != '' }}
@@ -327,6 +340,7 @@ runs:
327340
GOOGLE_CLOUD_ACCESS_TOKEN: '${{steps.auth.outputs.access_token}}'
328341
PROMPT: '${{ inputs.prompt }}'
329342
GEMINI_MODEL: '${{ inputs.gemini_model }}'
343+
GH_WORKFLOW_NAME: '${{ steps.sanitize_workflow_name.outputs.gh_workflow_name }}'
330344

331345
- name: 'Upload Gemini CLI outputs'
332346
if: |-

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ jobs:
6262
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
6363
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
6464
upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}'
65+
workflow_name: 'gemini-invoke'
6566
settings: |-
6667
{
6768
"model": {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ jobs:
108108
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
109109
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
110110
upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}'
111+
workflow_name: 'gemini-scheduled-triage'
111112
settings: |-
112113
{
113114
"model": {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ jobs:
7878
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
7979
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
8080
upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}'
81+
workflow_name: 'gemini-triage'
8182
settings: |-
8283
{
8384
"model": {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ jobs:
6464
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
6565
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
6666
upload_artifacts: '${{ vars.UPLOAD_ARTIFACTS }}'
67+
workflow_name: 'gemini-review'
6768
settings: |-
6869
{
6970
"model": {

0 commit comments

Comments
 (0)