Repository navigation
139 lines (139 loc) · 5.36 KB
/
Copy pathgemini-dispatch.yml
File metadata and controls
139 lines (139 loc) · 5.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: 🔀 Gemini Dispatch
on:
issues:
types:
- opened
- reopened
issue_comment:
types:
- created
defaults:
run:
shell: bash
jobs:
debugger:
if: |-
${{ fromJSON(vars.GEMINI_DEBUG || vars.ACTIONS_STEP_DEBUG || false) }}
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Print context for debugging
env:
DEBUG_event_name: ${{ github.event_name }}
DEBUG_event__action: ${{ github.event.action }}
DEBUG_event__comment__author_association: ${{ github.event.comment.author_association }}
DEBUG_event__issue__author_association: ${{ github.event.issue.author_association }}
DEBUG_event: ${{ toJSON(github.event) }}
run: |-
env | grep '^DEBUG_'
dispatch:
# For issues: only on open/reopen
# For comments: only if user types @gemini-cli and is OWNER/MEMBER/COLLABORATOR
if: |-
(
github.event_name == 'issues' &&
contains(fromJSON('["opened", "reopened"]'), github.event.action)
) || (
github.event.sender.type == 'User' &&
startsWith(github.event.comment.body || github.event.issue.body, '@gemini-cli') &&
contains(fromJSON('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association || github.event.issue.author_association)
)
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
outputs:
command: ${{ steps.extract_command.outputs.command }}
request: ${{ steps.extract_command.outputs.request }}
additional_context: ${{ steps.extract_command.outputs.additional_context }}
issue_number: ${{ github.event.issue.number }}
steps:
- name: Mint identity token
id: mint_identity_token
if: |-
${{ vars.APP_ID }}
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # ratchet:actions/create-github-app-token@v2
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
permission-contents: read
permission-issues: write
permission-pull-requests: write
- name: Extract command
id: extract_command
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # ratchet:actions/github-script@v7
env:
EVENT_TYPE: ${{ github.event_name }}.${{ github.event.action }}
REQUEST: ${{ github.event.comment.body || github.event.issue.body }}
with:
script: |
const eventType = process.env.EVENT_TYPE;
const request = process.env.REQUEST;
core.setOutput('request', request);
if (['issues.opened', 'issues.reopened'].includes(eventType)) {
core.setOutput('command', 'triage');
} else if (request.startsWith("@gemini-cli /triage")) {
core.setOutput('command', 'triage');
} else {
core.setOutput('command', 'fallthrough');
}
- name: Acknowledge request
env:
GITHUB_TOKEN: ${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
MESSAGE: |-
🤖 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.
REPOSITORY: ${{ github.repository }}
run: |-
gh issue comment "${ISSUE_NUMBER}" \
--body "${MESSAGE}" \
--repo "${REPOSITORY}"
triage:
needs: dispatch
if: |-
${{ needs.dispatch.outputs.command == 'triage' }}
uses: ./.github/workflows/gemini-triage.yml
permissions:
contents: read
id-token: write
issues: write
pull-requests: write
with:
additional_context: ${{ needs.dispatch.outputs.additional_context }}
secrets: inherit
fallthrough:
needs:
- dispatch
- triage
if: |-
${{ always() && !cancelled() && (failure() || needs.dispatch.outputs.command == 'fallthrough') }}
runs-on: ubuntu-latest
permissions:
contents: read
issues: write
pull-requests: write
steps:
- name: Mint identity token
id: mint_identity_token
if: |-
${{ vars.APP_ID }}
uses: actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf # ratchet:actions/create-github-app-token@v2
with:
app-id: ${{ vars.APP_ID }}
private-key: ${{ secrets.APP_PRIVATE_KEY }}
permission-contents: read
permission-issues: write
permission-pull-requests: write
- name: Send failure comment
env:
GITHUB_TOKEN: ${{ steps.mint_identity_token.outputs.token || secrets.GITHUB_TOKEN || github.token }}
ISSUE_NUMBER: ${{ github.event.issue.number }}
MESSAGE: |-
🤖 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.
REPOSITORY: ${{ github.repository }}
run: |-
gh issue comment "${ISSUE_NUMBER}" \
--body "${MESSAGE}" \
--repo "${REPOSITORY}"