Skip to content

Commit 1cc4172

Browse files
committed
ci: fix comment workflow for translations
1 parent a6b877f commit 1cc4172

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

.github/workflows/translation-ai-check.yml

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,17 +18,7 @@ permissions:
1818
jobs:
1919
review:
2020
name: Review Translation
21-
if: >
22-
${{
23-
github.event_name == 'pull_request' ||
24-
(
25-
github.event_name == 'issue_comment' &&
26-
github.event.action == 'created' &&
27-
github.event.issue.pull_request != null &&
28-
github.event.comment.user.login == 'vaxerski' &&
29-
github.event.comment.body == 'ai, please recheck'
30-
)
31-
}}
21+
if: ${{ github.event_name == 'pull_request' || (github.event_name == 'issue_comment' && github.event.action == 'created' && github.event.issue.pull_request != null && github.event.comment.user.login == 'vaxerski' && github.event.comment.body == 'ai, please recheck' ) }}
3222
runs-on: ubuntu-latest
3323
env:
3424
OPENAI_MODEL: gpt-5-mini
@@ -39,12 +29,26 @@ jobs:
3929
AI_PROMPT: Translation patch below.
4030

4131
steps:
32+
- name: Determine PR number
33+
id: pr
34+
run: |
35+
if [ "${{ github.event_name }}" = "pull_request" ]; then
36+
echo "number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
37+
else
38+
echo "number=${{ github.event.issue.number }}" >> "$GITHUB_OUTPUT"
39+
fi
40+
4241
- name: Download combined PR diff
4342
id: get_diff
43+
env:
44+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45+
PR_NUMBER: ${{ steps.pr.outputs.number }}
4446
run: |
4547
# Get the combined diff for the entire PR
4648
curl -sSL \
47-
"${{ github.event.pull_request.diff_url }}" \
49+
-H "Authorization: token $GITHUB_TOKEN" \
50+
-H "Accept: application/vnd.github.v3.diff" \
51+
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" \
4852
-o pr.diff
4953
5054
# Compute character length
@@ -63,12 +67,13 @@ jobs:
6367
if: steps.get_diff.outputs.too_long == 'true'
6468
env:
6569
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
70+
PR_NUMBER: ${{ steps.pr.outputs.number }}
6671
run: |
6772
jq -n --arg body "Diff length exceeded, can't query API" '{body: ("AI translation check result:\n\n" + $body)}' > body.json
6873
curl -sS -X POST \
6974
-H "Authorization: token $GITHUB_TOKEN" \
7075
-H "Content-Type: application/json" \
71-
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
76+
"https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \
7277
--data @body.json
7378
7479
- name: Query OpenAI and post review
@@ -79,6 +84,7 @@ jobs:
7984
SYSTEM_PROMPT: ${{ env.SYSTEM_PROMPT }}
8085
AI_PROMPT: ${{ env.AI_PROMPT }}
8186
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
PR_NUMBER: ${{ steps.pr.outputs.number }}
8288
run: |
8389
# Prepare OpenAI chat request payload (embed diff safely)
8490
jq -n \
@@ -110,5 +116,5 @@ jobs:
110116
curl -sS -X POST \
111117
-H "Authorization: token $GITHUB_TOKEN" \
112118
-H "Content-Type: application/json" \
113-
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
119+
"https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \
114120
--data @body.json

0 commit comments

Comments
 (0)