optimize: add translate #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: translate | |
on: | |
push: | |
branches: | |
- translate | |
permissions: | |
contents: write | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.x | |
- name: Cache dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ~/.cache/pip | |
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }} | |
restore-keys: | | |
${{ runner.os }}-pip- | |
- name: Change permissions | |
run: chmod 755 docs | |
- name: Auto-i18n_translate | |
env: | |
# 设置环境变量 | |
CHATGPT_API_KEY: ${{ secrets.CHATGPT_API_KEY }} | |
CHATGPT_API_BASE: ${{ secrets.CHATGPT_API_BASE }} | |
run: | | |
pip install -r requirements.txt | |
python auto-translater.py || true | |
- name: Commit translated | |
run: | | |
git config --global user.email [email protected] | |
git config --global user.name slievrly | |
git add . | |
git commit -m "Commit translated" || true | |
- name: Push changes | |
uses: ad-m/github-push-action@master | |
with: | |
github_token: ${{ secrets.COMMIT_TOKEN }} | |
branch: translate_docs | |
force: true |