mirror of
https://github.com/hyprwm/Hyprland
synced 2025-12-20 12:30:03 +01:00
ci: fix comment workflow for translations
This commit is contained in:
parent
a6b877fec2
commit
15b4b1dd91
1 changed files with 21 additions and 14 deletions
35
.github/workflows/translation-ai-check.yml
vendored
35
.github/workflows/translation-ai-check.yml
vendored
|
|
@ -18,17 +18,7 @@ permissions:
|
||||||
jobs:
|
jobs:
|
||||||
review:
|
review:
|
||||||
name: Review Translation
|
name: Review Translation
|
||||||
if: >
|
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' ) }}
|
||||||
${{
|
|
||||||
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'
|
|
||||||
)
|
|
||||||
}}
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
OPENAI_MODEL: gpt-5-mini
|
OPENAI_MODEL: gpt-5-mini
|
||||||
|
|
@ -39,12 +29,26 @@ jobs:
|
||||||
AI_PROMPT: Translation patch below.
|
AI_PROMPT: Translation patch below.
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
|
- name: Determine PR number
|
||||||
|
id: pr
|
||||||
|
run: |
|
||||||
|
if [ "${{ github.event_name }}" = "pull_request" ]; then
|
||||||
|
echo "number=${{ github.event.pull_request.number }}" >> "$GITHUB_OUTPUT"
|
||||||
|
else
|
||||||
|
echo "number=${{ github.event.issue.number }}" >> "$GITHUB_OUTPUT"
|
||||||
|
fi
|
||||||
|
|
||||||
- name: Download combined PR diff
|
- name: Download combined PR diff
|
||||||
id: get_diff
|
id: get_diff
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
PR_NUMBER: ${{ steps.pr.outputs.number }}
|
||||||
run: |
|
run: |
|
||||||
# Get the combined diff for the entire PR
|
# Get the combined diff for the entire PR
|
||||||
curl -sSL \
|
curl -sSL \
|
||||||
"${{ github.event.pull_request.diff_url }}" \
|
-H "Authorization: token $GITHUB_TOKEN" \
|
||||||
|
-H "Accept: application/vnd.github.v3.diff" \
|
||||||
|
"https://api.github.com/repos/${{ github.repository }}/pulls/$PR_NUMBER" \
|
||||||
-o pr.diff
|
-o pr.diff
|
||||||
|
|
||||||
# Compute character length
|
# Compute character length
|
||||||
|
|
@ -63,12 +67,13 @@ jobs:
|
||||||
if: steps.get_diff.outputs.too_long == 'true'
|
if: steps.get_diff.outputs.too_long == 'true'
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
PR_NUMBER: ${{ steps.pr.outputs.number }}
|
||||||
run: |
|
run: |
|
||||||
jq -n --arg body "Diff length exceeded, can't query API" '{body: ("AI translation check result:\n\n" + $body)}' > body.json
|
jq -n --arg body "Diff length exceeded, can't query API" '{body: ("AI translation check result:\n\n" + $body)}' > body.json
|
||||||
curl -sS -X POST \
|
curl -sS -X POST \
|
||||||
-H "Authorization: token $GITHUB_TOKEN" \
|
-H "Authorization: token $GITHUB_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
|
"https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \
|
||||||
--data @body.json
|
--data @body.json
|
||||||
|
|
||||||
- name: Query OpenAI and post review
|
- name: Query OpenAI and post review
|
||||||
|
|
@ -79,6 +84,7 @@ jobs:
|
||||||
SYSTEM_PROMPT: ${{ env.SYSTEM_PROMPT }}
|
SYSTEM_PROMPT: ${{ env.SYSTEM_PROMPT }}
|
||||||
AI_PROMPT: ${{ env.AI_PROMPT }}
|
AI_PROMPT: ${{ env.AI_PROMPT }}
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
PR_NUMBER: ${{ steps.pr.outputs.number }}
|
||||||
run: |
|
run: |
|
||||||
# Prepare OpenAI chat request payload (embed diff safely)
|
# Prepare OpenAI chat request payload (embed diff safely)
|
||||||
jq -n \
|
jq -n \
|
||||||
|
|
@ -107,8 +113,9 @@ jobs:
|
||||||
|
|
||||||
# Post the review as a PR comment
|
# Post the review as a PR comment
|
||||||
jq -n --arg body "$COMMENT" '{body: ("AI translation check result:\n\n" + $body)}' > body.json
|
jq -n --arg body "$COMMENT" '{body: ("AI translation check result:\n\n" + $body)}' > body.json
|
||||||
|
echo "CURLing https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments"
|
||||||
curl -sS -X POST \
|
curl -sS -X POST \
|
||||||
-H "Authorization: token $GITHUB_TOKEN" \
|
-H "Authorization: token $GITHUB_TOKEN" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
"https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments" \
|
"https://api.github.com/repos/${{ github.repository }}/issues/$PR_NUMBER/comments" \
|
||||||
--data @body.json
|
--data @body.json
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue