[Bug] 修复CI的bug (#105)

* 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
This commit is contained in:
qhy040404 2022-05-05 01:47:06 +08:00 committed by GitHub
parent 3d74adf44e
commit 414e3f8dd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,6 +1,6 @@
name: Auto-Translate name: Auto-Translate
on: on:
push: push:
branches: branches:
- 'main' - 'main'
@ -15,7 +15,7 @@ on:
- "README.md" - "README.md"
workflow_dispatch: workflow_dispatch:
jobs: jobs:
translate: translate:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -41,8 +41,8 @@ jobs:
shell: sh shell: sh
run: | run: |
mkdir parent mkdir parent
- name: Checkout parent commit - name: Download parent commit
shell: python shell: python
run: | run: |
import requests import requests
@ -69,12 +69,12 @@ jobs:
except Exception as e: except Exception as e:
print('Error') print('Error')
print(e) print(e)
un_zip('temp.zip') un_zip('temp.zip')
os.remove('temp.zip') os.remove('temp.zip')
os.system("cp parent/HowToLiveLonger-{}/README.md parent/README.md".format(parent_sha)) os.system("cp parent/HowToLiveLonger-{}/README.md parent/README.md".format(parent_sha))
- name: Compare and translate(Google) - name: Compare and translate(Google)
shell: python shell: python
run: | run: |
@ -97,7 +97,7 @@ jobs:
for i,item in enumerate(result): for i,item in enumerate(result):
if '+' in item: if '+' in item:
newlines.append(item.strip('\n')) newlines.append(item.strip('\n'))
for j,jtem in enumerate(newlines): for j,jtem in enumerate(newlines):
if newlines[j][0] != '+' or newlines[j] == '\n': if newlines[j][0] != '+' or newlines[j] == '\n':
del_list.append(j) del_list.append(j)
@ -105,12 +105,11 @@ jobs:
for a,atem in enumerate(del_list): for a,atem in enumerate(del_list):
newlines.pop(atem - a) newlines.pop(atem - a)
for k,ktem in enumerate(newlines): for k,ktem in enumerate(newlines):
# ktem = ktem.lstrip('+ ').lstrip('# ') # ktem = ktem.lstrip('+ ').lstrip('# ')
print(ktem) print(ktem)
newlines[k] = tl.translate(text=ktem, src='zh-cn', dest='en').text newlines[k] = tl.translate(text=ktem, src='zh-cn', dest='en').text
tlr = '\n\n'.join(newlines) tlr = '\n\n'.join(newlines)
with open("README_en.md","a") as tlf: with open("README_en.md","a") as tlf:
@ -131,7 +130,7 @@ jobs:
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3.0.2 uses: actions/checkout@v3.0.2
- name: Checkout new branch - name: Checkout new branch
shell: sh shell: sh
run: | run: |
@ -142,14 +141,17 @@ jobs:
uses: actions/download-artifact@v3.0.0 uses: actions/download-artifact@v3.0.0
with: with:
name: temp_trans_file name: temp_trans_file
- name: Git as GitHub Actions Bot
uses: Lucky3028/git-as-gha@v1.0.0
- name: Commit translation to review branch - name: Commit translation to review branch
shell: sh shell: sh
run: | run: |
git add . git add .
git commit -m "Auto translation for new lines" git commit -m "Auto translation for new lines"
git push origin auto-translation git push origin auto-translation
- name: Open PR and request reviews - name: Open PR and request reviews
uses: repo-sync/pull-request@master uses: repo-sync/pull-request@master
with: with: