Skip to content

Commit 28f7c68

Browse files
committed
feat(telemetry): set GHA_NAME dynamically from workflow
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 f7db4b6 commit 28f7c68

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ jobs:
2525
issues: 'write'
2626
pull-requests: 'write'
2727
steps:
28+
- name: 'Sanitize workflow name'
29+
id: 'sanitize_workflow_name'
30+
run: |
31+
# Remove emojis and special chars, convert spaces to underscores, lowercase
32+
SANITIZED=$(echo "${{ github.workflow }}" | sed 's/[^ a-zA-Z0-9]//g' | xargs | tr ' ' '_' | tr '[:upper:]' '[:lower:]')
33+
echo "gha_name=$SANITIZED" >> $GITHUB_OUTPUT
34+
2835
- name: 'Mint identity token'
2936
id: 'mint_identity_token'
3037
if: |-
@@ -49,6 +56,7 @@ jobs:
4956
ISSUE_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
5057
REPOSITORY: '${{ github.repository }}'
5158
ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}'
59+
GHA_NAME: '${{ steps.sanitize_workflow_name.outputs.gha_name }}'
5260
with:
5361
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
5462
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,13 @@ jobs:
8181
ISSUE_COUNT="$(echo "${ISSUES}" | jq 'length')"
8282
echo "✅ Found ${ISSUE_COUNT} issue(s) to triage! 🎯"
8383
84+
- name: 'Sanitize workflow name'
85+
id: 'sanitize_workflow_name'
86+
run: |
87+
# Remove emojis and special chars, convert spaces to underscores, lowercase
88+
SANITIZED=$(echo "${{ github.workflow }}" | sed 's/[^ a-zA-Z0-9]//g' | xargs | tr ' ' '_' | tr '[:upper:]' '[:lower:]')
89+
echo "gha_name=$SANITIZED" >> $GITHUB_OUTPUT
90+
8491
- name: 'Run Gemini Issue Analysis'
8592
id: 'gemini_issue_analysis'
8693
if: |-
@@ -91,6 +98,7 @@ jobs:
9198
ISSUES_TO_TRIAGE: '${{ steps.find_issues.outputs.issues_to_triage }}'
9299
REPOSITORY: '${{ github.repository }}'
93100
AVAILABLE_LABELS: '${{ steps.get_labels.outputs.available_labels }}'
101+
GHA_NAME: '${{ steps.sanitize_workflow_name.outputs.gha_name }}'
94102
with:
95103
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
96104
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@ jobs:
5151
core.info(`Found ${labelNames.length} labels: ${labelNames.join(', ')}`);
5252
return labelNames;
5353
54+
- name: 'Sanitize workflow name'
55+
id: 'sanitize_workflow_name'
56+
run: |
57+
# Remove emojis and special chars, convert spaces to underscores, lowercase
58+
SANITIZED=$(echo "${{ github.workflow }}" | sed 's/[^ a-zA-Z0-9]//g' | xargs | tr ' ' '_' | tr '[:upper:]' '[:lower:]')
59+
echo "gha_name=$SANITIZED" >> $GITHUB_OUTPUT
60+
5461
- name: 'Run Gemini issue analysis'
5562
id: 'gemini_analysis'
5663
if: |-
@@ -61,6 +68,7 @@ jobs:
6168
ISSUE_TITLE: '${{ github.event.issue.title }}'
6269
ISSUE_BODY: '${{ github.event.issue.body }}'
6370
AVAILABLE_LABELS: '${{ steps.get_labels.outputs.available_labels }}'
71+
GHA_NAME: '${{ steps.sanitize_workflow_name.outputs.gha_name }}'
6472
with:
6573
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
6674
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ jobs:
3838
permission-issues: 'write'
3939
permission-pull-requests: 'write'
4040

41+
- name: 'Sanitize workflow name'
42+
id: 'sanitize_workflow_name'
43+
run: |
44+
# Remove emojis and special chars, convert spaces to underscores, lowercase
45+
SANITIZED=$(echo "${{ github.workflow }}" | sed 's/[^ a-zA-Z0-9]//g' | xargs | tr ' ' '_' | tr '[:upper:]' '[:lower:]')
46+
echo "gha_name=$SANITIZED" >> $GITHUB_OUTPUT
47+
4148
- name: 'Checkout repository'
4249
uses: 'actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8' # ratchet:actions/checkout@v5
4350

@@ -51,6 +58,7 @@ jobs:
5158
PULL_REQUEST_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
5259
REPOSITORY: '${{ github.repository }}'
5360
ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}'
61+
GHA_NAME: '${{ steps.sanitize_workflow_name.outputs.gha_name }}'
5462
with:
5563
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
5664
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'

0 commit comments

Comments
 (0)