diff --git a/.github/workflows/releases.yml b/.github/workflows/releases.yml index 428b4f1..c013920 100644 --- a/.github/workflows/releases.yml +++ b/.github/workflows/releases.yml @@ -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: @@ -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: @@ -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 \ No newline at end of file diff --git a/README.md b/README.md index d3cd74a..f1eabde 100644 --- a/README.md +++ b/README.md @@ -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. @@ -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.