@@ -82,14 +82,22 @@ runs:
82
82
if : steps.detect_command.outputs.gptme_command
83
83
uses : actions/checkout@v3
84
84
85
- - name : Install ctags
86
- if : steps.detect_command.outputs.gptme_command
87
- run : sudo apt install universal-ctags
88
- shell : bash
85
+ - name : Log in to GitHub Container Registry
86
+ uses : docker/login-action@v3
87
+ with :
88
+ registry : ghcr.io
89
+ username : ${{ github.actor }}
90
+ password : ${{ secrets.GITHUB_TOKEN }}
91
+
92
+ - name : Pull Docker image
93
+ run : docker pull ghcr.io/erikbjare/gptme:latest
89
94
90
95
- name : Checkout PR branch if comment is on a PR
91
- if : steps.detect_command.outputs.gptme_command
92
96
id : checkout_branch
97
+ if : steps.detect_command.outputs.gptme_command
98
+ env :
99
+ GITHUB_TOKEN : ${{ inputs.github_token }}
100
+ shell : bash
93
101
run : |
94
102
# Fetch details about the "issue" the comment is on
95
103
DATA=$(gh api /repos/${{ github.repository }}/issues/${{ inputs.issue_number }})
@@ -112,65 +120,66 @@ runs:
112
120
git checkout -b $BRANCH_NAME
113
121
fi
114
122
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
115
- shell : bash
116
- env :
117
- GITHUB_TOKEN : ${{ inputs.github_token }}
118
-
119
- - name : Install poetry
120
- if : steps.detect_command.outputs.gptme_command
121
- run : pipx install poetry
122
- shell : bash
123
-
124
- - name : Set up Python
125
- uses : actions/setup-python@v4
126
- if : steps.detect_command.outputs.gptme_command
127
- with :
128
- python-version : ${{ inputs.python_version }}
129
- cache : ' poetry'
130
-
131
- - name : Install dependencies
132
- if : steps.detect_command.outputs.gptme_command
133
- run : |
134
- make build
135
- poetry install -E datascience
136
- shell : bash
137
123
138
124
- name : Run gptme
139
125
if : steps.detect_command.outputs.gptme_command
126
+ env :
127
+ GITHUB_TOKEN : ${{ inputs.github_token }}
128
+ GPTME_COMMAND : ${{ steps.detect_command.outputs.gptme_command }}
129
+ ISSUE_NUMBER : ${{ inputs.issue_number }}
130
+ OPENAI_API_KEY : ${{ inputs.openai_api_key }}
131
+ shell : bash
140
132
run : |
141
133
gh issue view ${{ inputs.issue_number }} > issue.md
142
134
gh issue view ${{ inputs.issue_number }} -c > comments.md
143
135
144
136
# strip long <details>...</details> from issue.md and comments.md
137
+ # TODO: upload logs elsewhere and link instead of dumping
145
138
perl -0777 -i -pe 's/\n<details>.*?<\/details>//sg' issue.md
146
139
perl -0777 -i -pe 's/\n<details>.*?<\/details>//sg' comments.md
147
140
148
- # install a shim that makes `git commit` a no-op (in case it would get that idea prematurely)
149
- source scripts/git-shim.sh
150
-
151
- # Run gptme with the extracted command and save logs
152
- poetry run gptme --non-interactive "$GPTME_COMMAND" issue.md comments.md
141
+ # run gptme with the extracted command and save logs
142
+ docker run --rm \
143
+ -v $(pwd):/workspace \
144
+ -w /workspace \
145
+ -e OPENAI_API_KEY=$OPENAI_API_KEY \
146
+ ghcr.io/erikbjare/gptme:latest \
147
+ --non-interactive \
148
+ "$GPTME_COMMAND" issue.md comments.md
153
149
154
150
# remove tmp files so that they do not get committed
155
151
rm issue.md comments.md
156
152
157
153
# stage changes
158
154
git add -A
159
- shell : bash
160
- env :
161
- GITHUB_TOKEN : ${{ inputs.github_token }}
162
- GPTME_COMMAND : ${{ steps.detect_command.outputs.gptme_command }}
163
- ISSUE_NUMBER : ${{ inputs.issue_number }}
164
155
165
156
- name : Generate commit message
166
157
if : steps.detect_command.outputs.gptme_command
158
+ shell : bash
159
+ env :
160
+ OPENAI_API_KEY : ${{ inputs.openai_api_key }}
167
161
run : |
168
162
# generate commit message
169
- poetry run gptme --non-interactive "Run `git diff --staged`, then write a commit message for it to message.txt, following conventional commits. Don't commit."
170
- shell : bash
163
+ docker run --rm \
164
+ -v $(pwd):/workspace \
165
+ -w /workspace \
166
+ -e OPENAI_API_KEY=$OPENAI_API_KEY \
167
+ ghcr.io/erikbjare/gptme:latest \
168
+ --non-interactive \
169
+ "Run 'git diff --staged' to inspect what has changed." "-" "Write a commit message for it to 'message.txt'. Use the 'conventional commits' style."
171
170
172
171
- name : Commit, push, comment
173
172
if : steps.detect_command.outputs.gptme_command
173
+ env :
174
+ GITHUB_TOKEN : ${{ inputs.github_token }}
175
+ GPTME_COMMAND : ${{ steps.detect_command.outputs.gptme_command }}
176
+ ISSUE_NUMBER : ${{ inputs.issue_number }}
177
+ ISSUE_TYPE : ${{ github.event.issue.pull_request && 'pull_request' || 'issue' }}
178
+ REPO_NAME : ${{ inputs.repo_name }}
179
+ USER_NAME : ${{ inputs.user_name }}
180
+ BRANCH_NAME : ${{ steps.checkout_branch.outputs.branch_name }}
181
+ BRANCH_BASE : ${{ inputs.branch_base }}
182
+ shell : bash
174
183
run : |
175
184
# Read and format log
176
185
./scripts/format_log.sh ~/.local/share/gptme/logs/*/conversation.jsonl > log.txt
@@ -220,19 +229,15 @@ runs:
220
229
# Comment on the issue with the PR link
221
230
echo "A pull request has been created for this issue: $PR_URL" | gh issue comment $ISSUE_NUMBER -R $USER_NAME/$REPO_NAME --body-file=-
222
231
fi
223
- shell : bash
232
+
233
+ - name : Report error
234
+ if : failure()
224
235
env :
225
236
GITHUB_TOKEN : ${{ inputs.github_token }}
226
- GPTME_COMMAND : ${{ steps.detect_command.outputs.gptme_command }}
227
237
ISSUE_NUMBER : ${{ inputs.issue_number }}
228
- ISSUE_TYPE : ${{ github.event.issue.pull_request && 'pull_request' || 'issue' }}
229
238
REPO_NAME : ${{ inputs.repo_name }}
230
239
USER_NAME : ${{ inputs.user_name }}
231
- BRANCH_NAME : ${{ steps.checkout_branch.outputs.branch_name }}
232
- BRANCH_BASE : ${{ inputs.branch_base }}
233
-
234
- - name : Report error
235
- if : failure()
240
+ shell : bash
236
241
run : |
237
242
# reply to the comment that we could not fulfill the request
238
243
RUN_URL="https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}"
@@ -245,9 +250,3 @@ runs:
245
250
</details>"
246
251
fi
247
252
echo "$MESSAGE" | gh issue comment $ISSUE_NUMBER -R $USER_NAME/$REPO_NAME --body-file=-
248
- shell : bash
249
- env :
250
- GITHUB_TOKEN : ${{ inputs.github_token }}
251
- ISSUE_NUMBER : ${{ inputs.issue_number }}
252
- REPO_NAME : ${{ inputs.repo_name }}
253
- USER_NAME : ${{ inputs.user_name }}
0 commit comments