From d0e90bff568e15bdc62ebb7f1b1d5637e6738107 Mon Sep 17 00:00:00 2001 From: Kai Tomotake Date: Thu, 11 Jun 2026 12:21:57 +0900 Subject: [PATCH 1/3] Add translation.yml --- .github/workflows/translation.yml | 83 +++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 .github/workflows/translation.yml diff --git a/.github/workflows/translation.yml b/.github/workflows/translation.yml new file mode 100644 index 0000000..1dda38a --- /dev/null +++ b/.github/workflows/translation.yml @@ -0,0 +1,83 @@ +name: Auto Translate + +concurrency: + group: auto-translate + cancel-in-progress: false + +on: + workflow_dispatch: + +jobs: + translate: + runs-on: ubuntu-latest + permissions: + models: read + contents: write + pull-requests: write + + steps: + - name: Checkout source branch + uses: actions/checkout@v6 + with: + ref: source + fetch-depth: 0 + + - name: Fetch main branch + run: git fetch origin main + + - name: Pick a random file + id: pick + run: | + target="$(find . -path './pr_created' -prune -o -type f -name '*.mdx' -print | shuf -n 1)" + if [ -z "$target" ]; then + echo 'No MDX files found' + exit 1 + fi + echo "target=$target" >> "$GITHUB_OUTPUT" + + - name: Translate with Deepseek + id: inference + uses: actions/ai-inference@v1 + with: + system-prompt: | + あなたの役割は翻訳者です。 + ユーザーが入力した文章を自然で正確な日本語に翻訳してください。 + 翻訳結果以外の説明、注釈、前置き、後書き、引用符は出力しないでください。 + 入力文に含まれる書式(改行や段落)は、可能な限り維持してください。 + prompt-file: ${{ steps.pick.outputs.target }} + model: deepseek/deepseek-v3-0324 + + - name: Commit translated file + id: commit + run: | + path="contents/docs/${{ steps.pick.outputs.target }}" + branch="translate-$(uuidgen | cut -c1-8)" + git config user.name 'github-actions' + git config user.email 'github-actions@users.noreply.github.com' + git checkout -b $branch origin/main + mkdir -p "$(dirname "$path")" + cp "${{ steps.inference.outputs.response-file }}" "$path" + git add "$path" + git commit -m "Translate ${{ steps.pick.outputs.target }}" + git push -u origin "$branch" + echo "branch=$branch" >> "$GITHUB_OUTPUT" + + - name: Create PR + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr create \ + --base main \ + --head "${{ steps.commit.outputs.branch }}" \ + --title "Translate ${{ steps.pick.outputs.target }}" \ + --body 'Auto-generated translation PR' + + - name: Move the file + run: | + git checkout source + dest="pr_created/${{ steps.pick.outputs.target }}" + mkdir -p "$(dirname "$dest")" + git mv "${{ steps.pick.outputs.target }}" "$dest" + git add "$dest" + git commit -m 'Move PR-created file to pr_created' + git push -u origin source From 7af85c6daed14da389bbb78b1e98ed4a241f2c86 Mon Sep 17 00:00:00 2001 From: Kai Tomotake Date: Thu, 11 Jun 2026 14:51:33 +0900 Subject: [PATCH 2/3] fix --- .github/workflows/translation.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/translation.yml b/.github/workflows/translation.yml index 1dda38a..71f1f1e 100644 --- a/.github/workflows/translation.yml +++ b/.github/workflows/translation.yml @@ -46,7 +46,7 @@ jobs: 入力文に含まれる書式(改行や段落)は、可能な限り維持してください。 prompt-file: ${{ steps.pick.outputs.target }} model: deepseek/deepseek-v3-0324 - + - name: Commit translated file id: commit run: | From 98054bf420fa252aff04ba61940f11a8be7cd067 Mon Sep 17 00:00:00 2001 From: Kai Tomotake Date: Sat, 13 Jun 2026 17:15:52 +0900 Subject: [PATCH 3/3] fix format --- .github/workflows/translation.yml | 166 +++++++++++++++--------------- 1 file changed, 83 insertions(+), 83 deletions(-) diff --git a/.github/workflows/translation.yml b/.github/workflows/translation.yml index 71f1f1e..70b9d16 100644 --- a/.github/workflows/translation.yml +++ b/.github/workflows/translation.yml @@ -1,83 +1,83 @@ -name: Auto Translate - -concurrency: - group: auto-translate - cancel-in-progress: false - -on: - workflow_dispatch: - -jobs: - translate: - runs-on: ubuntu-latest - permissions: - models: read - contents: write - pull-requests: write - - steps: - - name: Checkout source branch - uses: actions/checkout@v6 - with: - ref: source - fetch-depth: 0 - - - name: Fetch main branch - run: git fetch origin main - - - name: Pick a random file - id: pick - run: | - target="$(find . -path './pr_created' -prune -o -type f -name '*.mdx' -print | shuf -n 1)" - if [ -z "$target" ]; then - echo 'No MDX files found' - exit 1 - fi - echo "target=$target" >> "$GITHUB_OUTPUT" - - - name: Translate with Deepseek - id: inference - uses: actions/ai-inference@v1 - with: - system-prompt: | - あなたの役割は翻訳者です。 - ユーザーが入力した文章を自然で正確な日本語に翻訳してください。 - 翻訳結果以外の説明、注釈、前置き、後書き、引用符は出力しないでください。 - 入力文に含まれる書式(改行や段落)は、可能な限り維持してください。 - prompt-file: ${{ steps.pick.outputs.target }} - model: deepseek/deepseek-v3-0324 - - - name: Commit translated file - id: commit - run: | - path="contents/docs/${{ steps.pick.outputs.target }}" - branch="translate-$(uuidgen | cut -c1-8)" - git config user.name 'github-actions' - git config user.email 'github-actions@users.noreply.github.com' - git checkout -b $branch origin/main - mkdir -p "$(dirname "$path")" - cp "${{ steps.inference.outputs.response-file }}" "$path" - git add "$path" - git commit -m "Translate ${{ steps.pick.outputs.target }}" - git push -u origin "$branch" - echo "branch=$branch" >> "$GITHUB_OUTPUT" - - - name: Create PR - env: - GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gh pr create \ - --base main \ - --head "${{ steps.commit.outputs.branch }}" \ - --title "Translate ${{ steps.pick.outputs.target }}" \ - --body 'Auto-generated translation PR' - - - name: Move the file - run: | - git checkout source - dest="pr_created/${{ steps.pick.outputs.target }}" - mkdir -p "$(dirname "$dest")" - git mv "${{ steps.pick.outputs.target }}" "$dest" - git add "$dest" - git commit -m 'Move PR-created file to pr_created' - git push -u origin source +name: Auto Translate + +concurrency: + group: auto-translate + cancel-in-progress: false + +on: + workflow_dispatch: + +jobs: + translate: + runs-on: ubuntu-latest + permissions: + models: read + contents: write + pull-requests: write + + steps: + - name: Checkout source branch + uses: actions/checkout@v6 + with: + ref: source + fetch-depth: 0 + + - name: Fetch main branch + run: git fetch origin main + + - name: Pick a random file + id: pick + run: | + target="$(find . -path './pr_created' -prune -o -type f -name '*.mdx' -print | shuf -n 1)" + if [ -z "$target" ]; then + echo 'No MDX files found' + exit 1 + fi + echo "target=$target" >> "$GITHUB_OUTPUT" + + - name: Translate with Deepseek + id: inference + uses: actions/ai-inference@v1 + with: + system-prompt: | + あなたの役割は翻訳者です。 + ユーザーが入力した文章を自然で正確な日本語に翻訳してください。 + 翻訳結果以外の説明、注釈、前置き、後書き、引用符は出力しないでください。 + 入力文に含まれる書式(改行や段落)は、可能な限り維持してください。 + prompt-file: ${{ steps.pick.outputs.target }} + model: deepseek/deepseek-v3-0324 + + - name: Commit translated file + id: commit + run: | + path="contents/docs/${{ steps.pick.outputs.target }}" + branch="translate-$(uuidgen | cut -c1-8)" + git config user.name 'github-actions' + git config user.email 'github-actions@users.noreply.github.com' + git checkout -b $branch origin/main + mkdir -p "$(dirname "$path")" + cp "${{ steps.inference.outputs.response-file }}" "$path" + git add "$path" + git commit -m "Translate ${{ steps.pick.outputs.target }}" + git push -u origin "$branch" + echo "branch=$branch" >> "$GITHUB_OUTPUT" + + - name: Create PR + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + run: | + gh pr create \ + --base main \ + --head "${{ steps.commit.outputs.branch }}" \ + --title "Translate ${{ steps.pick.outputs.target }}" \ + --body 'Auto-generated translation PR' + + - name: Move the file + run: | + git checkout source + dest="pr_created/${{ steps.pick.outputs.target }}" + mkdir -p "$(dirname "$dest")" + git mv "${{ steps.pick.outputs.target }}" "$dest" + git add "$dest" + git commit -m 'Move PR-created file to pr_created' + git push -u origin source