Skip to content

Commit c05f558

Browse files
RD-1175: Add additional workflows (#56)
1 parent 1e3d478 commit c05f558

File tree

7 files changed

+1486
-1
lines changed

7 files changed

+1486
-1
lines changed

.github/workflows/autoprv3.yaml

Lines changed: 186 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,186 @@
1+
name: Automated PR
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
issue_key:
7+
description: 'Issue key'
8+
required: true
9+
issue_summary:
10+
description: 'Brief summary of the issue'
11+
required: true
12+
issue_description:
13+
description: 'Detailed issue description'
14+
required: true
15+
16+
permissions:
17+
contents: write
18+
pull-requests: write
19+
20+
jobs:
21+
automate:
22+
runs-on: ubuntu-latest
23+
24+
steps:
25+
26+
# Set up developer tools
27+
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
with:
31+
fetch-depth: 0
32+
submodules: recursive
33+
34+
- name: Set up JDK
35+
uses: actions/setup-java@v4
36+
with:
37+
distribution: 'temurin'
38+
java-version: '21'
39+
40+
- name: Set up Gradle
41+
uses: gradle/actions/setup-gradle@v3
42+
43+
- name: Set up Node.js
44+
uses: actions/setup-node@v4
45+
with:
46+
node-version: '20'
47+
48+
# Symlink agents file to the root
49+
50+
- name: Symlink agents
51+
run: ln -s .github/copilot-instructions.md AGENTS.md
52+
53+
# Generate JS docs
54+
- name: Set up Node
55+
uses: actions/setup-node@v4
56+
with:
57+
node-version: 22
58+
59+
- name: Install JS deps
60+
working-directory: js
61+
run: npm ci
62+
63+
- name: Build JS docs
64+
working-directory: js
65+
run: npm run doc
66+
67+
# Set up environment variables
68+
69+
- name: Prepare variables
70+
run: |
71+
echo "ISSUE_KEY=${{ github.event.inputs.issue_key }}" >> $GITHUB_ENV
72+
echo "TITLE=${{ github.event.inputs.issue_summary }}" >> $GITHUB_ENV
73+
DESC_CLEANED=$(echo "${{ github.event.inputs.issue_description }}" | tr '\n' ' ' | sed 's/"/'\''/g')
74+
echo "DESC=$DESC_CLEANED" >> $GITHUB_ENV
75+
echo "BRANCH=${{ github.event.inputs.issue_key }}" >> $GITHUB_ENV
76+
77+
# Set up LLM Agent
78+
79+
- name: Install Codex (npm)
80+
run: npm i -g @openai/codex
81+
82+
# Run the LLM Agent and commit the output
83+
84+
- name: 'Run Gemini CLI'
85+
id: 'run_gemini'
86+
uses: 'google-github-actions/run-gemini-cli@v0' # ratchet:exclude
87+
env:
88+
GITHUB_TOKEN: '${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}'
89+
IS_PULL_REQUEST: '${{ !!github.event.pull_request }}'
90+
REPOSITORY: '${{ github.repository }}'
91+
ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}'
92+
AGENT_DIRECTIVES: '${{ steps.agent_directives.outputs.directives }}'
93+
with:
94+
gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
95+
gcp_workload_identity_provider: '${{ vars.GCP_WIF_PROVIDER }}'
96+
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
97+
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
98+
gcp_service_account: '${{ vars.SERVICE_ACCOUNT_EMAIL }}'
99+
use_vertex_ai: '${{ vars.GOOGLE_GENAI_USE_VERTEXAI }}'
100+
google_api_key: '${{ secrets.GOOGLE_API_KEY }}'
101+
use_gemini_code_assist: '${{ vars.GOOGLE_GENAI_USE_GCA }}'
102+
gemini_debug: '${{ fromJSON(vars.DEBUG || vars.ACTIONS_STEP_DEBUG || false) }}'
103+
gemini_model: '${{ vars.GEMINI_MODEL }}'
104+
settings: |-
105+
{
106+
"maxSessionTurns": 25,
107+
"telemetry": {
108+
"enabled": ${{ vars.GOOGLE_CLOUD_PROJECT != '' }},
109+
"target": "gcp"
110+
},
111+
"mcpServers": {
112+
"github": {
113+
"command": "docker",
114+
"args": [
115+
"run",
116+
"-i",
117+
"--rm",
118+
"-e",
119+
"GITHUB_PERSONAL_ACCESS_TOKEN",
120+
"ghcr.io/github/github-mcp-server"
121+
],
122+
"includeTools": [
123+
"add_issue_comment",
124+
"get_issue",
125+
"get_issue_comments",
126+
"list_issues",
127+
"search_issues",
128+
"create_pull_request",
129+
"get_pull_request",
130+
"get_pull_request_comments",
131+
"get_pull_request_diff",
132+
"get_pull_request_files",
133+
"list_pull_requests",
134+
"search_pull_requests",
135+
"create_branch",
136+
"create_or_update_file",
137+
"delete_file",
138+
"fork_repository",
139+
"get_commit",
140+
"get_file_contents",
141+
"list_commits",
142+
"push_files",
143+
"search_code"
144+
],
145+
"env": {
146+
"GITHUB_PERSONAL_ACCESS_TOKEN": "${GITHUB_TOKEN}"
147+
}
148+
}
149+
},
150+
"coreTools": [
151+
"run_shell_command(cat)",
152+
"run_shell_command(echo)",
153+
"run_shell_command(grep)",
154+
"run_shell_command(head)",
155+
"run_shell_command(tail)"
156+
] }
157+
prompt: |-
158+
${{ env.AGENT_DIRECTIVES }}
159+
Implement ticket ${{ env.ISSUE_KEY }}: ${{ env.TITLE }}. ${{ env.DESC }}
160+
- name: Agent commit
161+
run: |
162+
git add -A
163+
git commit -m "$ISSUE_KEY: $TITLE"
164+
165+
# Prepare and push Pull Request
166+
167+
- id: cpr
168+
name: Create Pull Request
169+
uses: peter-evans/create-pull-request@v6
170+
with:
171+
token: ${{ secrets.GITHUB_TOKEN }}
172+
base: main
173+
branch: ${{ env.BRANCH }}
174+
title: "${{ env.ISSUE_KEY }}: ${{ env.TITLE }}"
175+
body: |
176+
**${{ env.ISSUE_KEY }}**
177+
178+
## Objective
179+
**${{ env.TITLE }}**.
180+
181+
## Description
182+
${{ env.DESC }}
183+
184+
## Acceptance
185+
Compiles and checks pass.
186+
Lines changed: 204 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,204 @@
1+
name: '🔀 Gemini Dispatch'
2+
3+
on:
4+
pull_request_review_comment:
5+
types:
6+
- 'created'
7+
pull_request_review:
8+
types:
9+
- 'submitted'
10+
pull_request:
11+
types:
12+
- 'opened'
13+
issues:
14+
types:
15+
- 'opened'
16+
- 'reopened'
17+
issue_comment:
18+
types:
19+
- 'created'
20+
21+
defaults:
22+
run:
23+
shell: 'bash'
24+
25+
jobs:
26+
debugger:
27+
if: |-
28+
${{ fromJSON(vars.DEBUG || vars.ACTIONS_STEP_DEBUG || false) }}
29+
runs-on: 'ubuntu-latest'
30+
permissions:
31+
contents: 'read'
32+
steps:
33+
- name: 'Print context for debugging'
34+
env:
35+
DEBUG_event_name: '${{ github.event_name }}'
36+
DEBUG_event__action: '${{ github.event.action }}'
37+
DEBUG_event__comment__author_association: '${{ github.event.comment.author_association }}'
38+
DEBUG_event__issue__author_association: '${{ github.event.issue.author_association }}'
39+
DEBUG_event__pull_request__author_association: '${{ github.event.pull_request.author_association }}'
40+
DEBUG_event__review__author_association: '${{ github.event.review.author_association }}'
41+
DEBUG_event: '${{ toJSON(github.event) }}'
42+
run: |-
43+
env | grep '^DEBUG_'
44+
45+
dispatch:
46+
# For PRs: only if not from a fork
47+
# For comments: only if user types @gemini-cli and is OWNER/MEMBER/COLLABORATOR
48+
# For issues: only on open/reopen
49+
if: |-
50+
(
51+
github.event_name == 'pull_request' &&
52+
github.event.pull_request.head.repo.fork == false
53+
) || (
54+
github.event.sender.type == 'User' &&
55+
startsWith(github.event.comment.body || github.event.review.body || github.event.issue.body, '@gemini-cli') &&
56+
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association || github.event.review.author_association || github.event.issue.author_association)
57+
) || (
58+
github.event_name == 'issues' &&
59+
contains(fromJSON('["opened", "reopened"]'), github.event.action)
60+
)
61+
runs-on: 'ubuntu-latest'
62+
permissions:
63+
contents: 'read'
64+
issues: 'write'
65+
pull-requests: 'write'
66+
outputs:
67+
command: '${{ steps.extract_command.outputs.command }}'
68+
request: '${{ steps.extract_command.outputs.request }}'
69+
additional_context: '${{ steps.extract_command.outputs.additional_context }}'
70+
issue_number: '${{ github.event.pull_request.number || github.event.issue.number }}'
71+
steps:
72+
- name: 'Mint identity token'
73+
id: 'mint_identity_token'
74+
if: |-
75+
${{ vars.APP_ID }}
76+
uses: 'actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b' # ratchet:actions/create-github-app-token@v2
77+
with:
78+
app-id: '${{ vars.APP_ID }}'
79+
private-key: '${{ secrets.APP_PRIVATE_KEY }}'
80+
permission-contents: 'read'
81+
permission-issues: 'write'
82+
permission-pull-requests: 'write'
83+
84+
- name: 'Extract command'
85+
id: 'extract_command'
86+
uses: 'actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea' # ratchet:actions/github-script@v7
87+
env:
88+
EVENT_TYPE: '${{ github.event_name }}.${{ github.event.action }}'
89+
REQUEST: '${{ github.event.comment.body || github.event.review.body || github.event.issue.body }}'
90+
with:
91+
script: |
92+
const request = process.env.REQUEST;
93+
const eventType = process.env.EVENT_TYPE
94+
core.setOutput('request', request);
95+
96+
if (request.startsWith("@gemini-cli /review")) {
97+
core.setOutput('command', 'review');
98+
const additionalContext = request.replace(/^@gemini-cli \/review/, '').trim();
99+
core.setOutput('additional_context', additionalContext);
100+
} else if (request.startsWith("@gemini-cli /triage")) {
101+
core.setOutput('command', 'triage');
102+
} else if (request.startsWith("@gemini-cli")) {
103+
core.setOutput('command', 'invoke');
104+
const additionalContext = request.replace(/^@gemini-cli/, '').trim();
105+
core.setOutput('additional_context', additionalContext);
106+
} else if (eventType === 'pull_request.opened') {
107+
core.setOutput('command', 'review');
108+
} else if (['issues.opened', 'issues.reopened'].includes(eventType)) {
109+
core.setOutput('command', 'triage');
110+
} else {
111+
core.setOutput('command', 'fallthrough');
112+
}
113+
114+
- name: 'Acknowledge request'
115+
env:
116+
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 }}'
118+
MESSAGE: |-
119+
🤖 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.
120+
REPOSITORY: '${{ github.repository }}'
121+
run: |-
122+
gh issue comment "${ISSUE_NUMBER}" \
123+
--body "${MESSAGE}" \
124+
--repo "${REPOSITORY}"
125+
126+
review:
127+
needs: 'dispatch'
128+
if: |-
129+
${{ needs.dispatch.outputs.command == 'review' }}
130+
uses: './.github/workflows/gemini-review.yml'
131+
permissions:
132+
contents: 'read'
133+
id-token: 'write'
134+
issues: 'write'
135+
pull-requests: 'write'
136+
with:
137+
additional_context: '${{ needs.dispatch.outputs.additional_context }}'
138+
secrets: 'inherit'
139+
140+
triage:
141+
needs: 'dispatch'
142+
if: |-
143+
${{ needs.dispatch.outputs.command == 'triage' }}
144+
uses: './.github/workflows/gemini-triage.yml'
145+
permissions:
146+
contents: 'read'
147+
id-token: 'write'
148+
issues: 'write'
149+
pull-requests: 'write'
150+
with:
151+
additional_context: '${{ needs.dispatch.outputs.additional_context }}'
152+
secrets: 'inherit'
153+
154+
invoke:
155+
needs: 'dispatch'
156+
if: |-
157+
${{ needs.dispatch.outputs.command == 'invoke' }}
158+
uses: './.github/workflows/gemini-invoke.yml'
159+
permissions:
160+
contents: 'read'
161+
id-token: 'write'
162+
issues: 'write'
163+
pull-requests: 'write'
164+
with:
165+
additional_context: '${{ needs.dispatch.outputs.additional_context }}'
166+
secrets: 'inherit'
167+
168+
fallthrough:
169+
needs:
170+
- 'dispatch'
171+
- 'review'
172+
- 'triage'
173+
- 'invoke'
174+
if: |-
175+
${{ always() && !cancelled() && (failure() || needs.dispatch.outputs.command == 'fallthrough') }}
176+
runs-on: 'ubuntu-latest'
177+
permissions:
178+
contents: 'read'
179+
issues: 'write'
180+
pull-requests: 'write'
181+
steps:
182+
- name: 'Mint identity token'
183+
id: 'mint_identity_token'
184+
if: |-
185+
${{ vars.APP_ID }}
186+
uses: 'actions/create-github-app-token@a8d616148505b5069dccd32f177bb87d7f39123b' # ratchet:actions/create-github-app-token@v2
187+
with:
188+
app-id: '${{ vars.APP_ID }}'
189+
private-key: '${{ secrets.APP_PRIVATE_KEY }}'
190+
permission-contents: 'read'
191+
permission-issues: 'write'
192+
permission-pull-requests: 'write'
193+
194+
- name: 'Send failure comment'
195+
env:
196+
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 }}'
198+
MESSAGE: |-
199+
🤖 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.
200+
REPOSITORY: '${{ github.repository }}'
201+
run: |-
202+
gh issue comment "${ISSUE_NUMBER}" \
203+
--body "${MESSAGE}" \
204+
--repo "${REPOSITORY}"

0 commit comments

Comments
 (0)