Documentation
Examples
By Command

Command Based

Translate by typing commands in the comments of Issues or PR.

Workflow Settings Overview

gpt-translate.yml
name: GPT Translate
 
on:
  issue_comment:
    types: [created]
 
jobs:
  gpt_translate:
    runs-on: ubuntu-latest
 
    steps:
      - uses: actions/checkout@v3
 
      - name: Run GPT Translate
        if: |
          contains(github.event.comment.body, '/gpt-translate') ||
          contains(github.event.comment.body, '/gt')
        uses: 3ru/gpt-translate@master
        with:
          apikey: ${{ secrets.OPENAI_API_KEY }}

Explanation

on:
  issue_comment:
    types: [created]

Each time an issue or pull request comment is created, actions is launched.


steps:
  - uses: actions/checkout@v3

Check out the repository to the ubuntu environment. This will give gpt-translate access to the files in the repository for translation.

In other words, you must always check out the repository in advance.


- name: Run GPT Translate
  if: |
    contains(github.event.comment.body, '/gpt-translate') ||
    contains(github.event.comment.body, '/gt')
  uses: 3ru/gpt-translate@master
  with:
    apikey: ${{ secrets.OPENAI_API_KEY }}

Specifies the conditions under which gpt-translate is executed.

Here, if /gpt-translate or /gt is included in the comment, it moves to the next process.


- name: Run GPT Translate
  if: |
    contains(github.event.comment.body, '/gpt-translate') ||
    contains(github.event.comment.body, '/gt')
  uses: 3ru/gpt-translate@master
  with:
    apikey: ${{ secrets.OPENAI_API_KEY }}

Run with v1.1 gpt-translate action.

Instead of specifying a specific version, you can specify a major version @1 or a branch @master. GitHub Docs: Using a public action (opens in a new tab)


with:
  apikey: ${{ secrets.OPENAI_API_KEY }}

Pass the OpenAI API Key from the repository secret (encrypted)