From 414e3f8dd27a3b39fd2f1684ebaa4c43655c7f71 Mon Sep 17 00:00:00 2001 From: qhy040404 <45379733+qhy040404@users.noreply.github.com> Date: Thu, 5 May 2022 01:47:06 +0800 Subject: [PATCH] =?UTF-8?q?[Bug]=20=E4=BF=AE=E5=A4=8DCI=E7=9A=84bug=20(#10?= =?UTF-8?q?5)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Finish CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Fix CI * Update English version * Fix CI bugs * Remove trailing spaces --- .github/workflows/auto-translate.yml | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/.github/workflows/auto-translate.yml b/.github/workflows/auto-translate.yml index a7232d8..30b8846 100644 --- a/.github/workflows/auto-translate.yml +++ b/.github/workflows/auto-translate.yml @@ -1,6 +1,6 @@ name: Auto-Translate -on: +on: push: branches: - 'main' @@ -15,7 +15,7 @@ on: - "README.md" workflow_dispatch: - + jobs: translate: runs-on: ubuntu-latest @@ -41,8 +41,8 @@ jobs: shell: sh run: | mkdir parent - - - name: Checkout parent commit + + - name: Download parent commit shell: python run: | import requests @@ -69,12 +69,12 @@ jobs: except Exception as e: print('Error') print(e) - + un_zip('temp.zip') os.remove('temp.zip') os.system("cp parent/HowToLiveLonger-{}/README.md parent/README.md".format(parent_sha)) - + - name: Compare and translate(Google) shell: python run: | @@ -97,7 +97,7 @@ jobs: for i,item in enumerate(result): if '+' in item: newlines.append(item.strip('\n')) - + for j,jtem in enumerate(newlines): if newlines[j][0] != '+' or newlines[j] == '\n': del_list.append(j) @@ -105,12 +105,11 @@ jobs: for a,atem in enumerate(del_list): newlines.pop(atem - a) - for k,ktem in enumerate(newlines): # ktem = ktem.lstrip('+ ').lstrip('# ') print(ktem) newlines[k] = tl.translate(text=ktem, src='zh-cn', dest='en').text - + tlr = '\n\n'.join(newlines) with open("README_en.md","a") as tlf: @@ -131,7 +130,7 @@ jobs: steps: - name: Checkout code uses: actions/checkout@v3.0.2 - + - name: Checkout new branch shell: sh run: | @@ -142,14 +141,17 @@ jobs: uses: actions/download-artifact@v3.0.0 with: name: temp_trans_file - + + - name: Git as GitHub Actions Bot + uses: Lucky3028/git-as-gha@v1.0.0 + - name: Commit translation to review branch shell: sh run: | git add . git commit -m "Auto translation for new lines" git push origin auto-translation - + - name: Open PR and request reviews uses: repo-sync/pull-request@master with: