Skip to content

Commit

Permalink
Update README to use docker.
Browse files Browse the repository at this point in the history
  • Loading branch information
winlinvip committed Jul 29, 2023
1 parent a9b1b70 commit 3659851
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/releases.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
run: |
SRS_TAG=$(echo ${{ github.ref }}| awk -F '/' '{print $3}')
echo "SRS_TAG=$SRS_TAG" >> $GITHUB_ENV
SRS_MAJOR=$(echo $SRS_TAG| awk -F '.' '{print $1}' |sed 's/-v/-/g')
SRS_MAJOR=$(echo $SRS_TAG| awk -F '.' '{print $1}' |sed 's/v//g')
echo "SRS_MAJOR=$SRS_MAJOR" >> $GITHUB_ENV
# Map a step output to a job output, see https://docs.github.com/en/actions/using-jobs/defining-outputs-for-jobs
outputs:
Expand Down Expand Up @@ -59,6 +59,7 @@ jobs:
dst: |
ossrs/issues-translation:${{ env.SRS_MAJOR }}
ossrs/issues-translation:v${{ env.SRS_MAJOR }}
ossrs/issues-translation:latest
runs-on: ubuntu-20.04

aliyun:
Expand All @@ -85,4 +86,5 @@ jobs:
registry.cn-hangzhou.aliyuncs.com/ossrs/issues-translation:${{ env.SRS_TAG }}
registry.cn-hangzhou.aliyuncs.com/ossrs/issues-translation:${{ env.SRS_MAJOR }}
registry.cn-hangzhou.aliyuncs.com/ossrs/issues-translation:v${{ env.SRS_MAJOR }}
registry.cn-hangzhou.aliyuncs.com/ossrs/issues-translation:latest
runs-on: ubuntu-20.04
42 changes: 34 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,38 @@ Use AI/GPT to translate GitHub issues into English.

## Usage

Setup OpenAI API key and GitHub token:
Use docker to translate issue:

```bash
export GITHUB_TOKEN=xxx
export OPENAI_API_KEY=xxx
export OPENAI_PROXY=xxx
docker run --rm -it -e GITHUB_TOKEN=xxx -e OPENAI_API_KEY=xxx -e OPENAI_PROXY=xxx ossrs/issues-translation:v1 \
python issue-trans.py --input https://github.com/your-org/your-repository/issues/3692
```

Use docker to translate discussion:

```bash
docker run --rm -it -e GITHUB_TOKEN=xxx -e OPENAI_API_KEY=xxx -e OPENAI_PROXY=xxx ossrs/issues-translation:v1 \
python discussion-trans.py --input https://github.com/your-org/your-repository/discussions/3700
```

Use docker to translate PR:

```bash
docker run --rm -it -e GITHUB_TOKEN=xxx -e OPENAI_API_KEY=xxx -e OPENAI_PROXY=xxx ossrs/issues-translation:v1 \
python pr-trans.py --input https://github.com/your-org/your-repository/pull/3699
```

Also you can use `--env-file=$(pwd)/.env` to load the environment variables from file `.env`.

## Developer

Write a `.env` file to setup OpenAI API key and GitHub token:

```bash
#.env
GITHUB_TOKEN=xxx
OPENAI_API_KEY=xxx
OPENAI_PROXY=xxx
```

> Note: The `GITHUB_TOKEN` is required to update the issue ,please read [Authenticating to the REST API](https://docs.github.com/en/rest/overview/authenticating-to-the-rest-api) to create one.
Expand All @@ -33,20 +59,20 @@ pip install -r requirements.txt
Translate issues to English:

```bash
python issue-trans.py --input=https://github.com/your-org/your-repository/issues/3692
python issue-trans.py --input https://github.com/your-org/your-repository/issues/3692
```

Translate issues to English:

```bash
python pr-trans.py --input=https://github.com/your-org/your-repository/pull/3699
python pr-rephrase.py --input=https://github.com/your-org/your-repository/pull/3699
python pr-trans.py --input https://github.com/your-org/your-repository/pull/3699
python pr-rephrase.py --input https://github.com/your-org/your-repository/pull/3699
```

Translate discussions to English:

```bash
python discussion-trans.py --input=https://github.com/your-org/your-repository/discussions/3700
python discussion-trans.py --input https://github.com/your-org/your-repository/discussions/3700
```

Once translated, this tool appends a MAGIC string to the conclusion of the text body to prevent repeated translations.
Expand Down

0 comments on commit 3659851

Please sign in to comment.