transform: METADATA and METADATA (#2216) #674
This file contains hidden or 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: GPT Translate per Commit | |
on: | |
push: | |
branches: | |
- main | |
paths-ignore: | |
- ".github**/*" | |
- "docs/cn/**/*" | |
- "docs/release-notes/**/*" | |
- "docs/fragment/**/*" | |
- "docs/release-stable/**/*" | |
- "api/**/*" | |
- "i18n/**/*" | |
- "src/**/*" | |
- "static/**/*" | |
- "types/**/*" | |
- "README.md" | |
jobs: | |
gpt_translate: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository with two latest commits | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
- name: get changed files name | |
id: changed_files | |
run: | | |
echo "files=$(git diff --diff-filter=d --name-only HEAD^ HEAD | grep '\.md$' | grep -v 'cn' | sed -e 's/^/.\//' | tr '\n' ' ')" >> $GITHUB_OUTPUT | |
- name: Read prompt from file | |
id: prompt | |
run: | | |
prompt_value=$(cat .github/workflows/prompt.txt | sed ':a;N;$!ba;s/\n/\\n/g') | |
echo "prompt=$prompt_value" >> $GITHUB_OUTPUT | |
- name: Run GPT Translate | |
uses: 3ru/[email protected] | |
with: | |
apikey: ${{ secrets.API_KEY }} | |
model: ${{ secrets.LLM_MODEL }} | |
inputFiles: "${{ steps.changed_files.outputs.files }}" | |
outputFiles: "docs/cn/**/*.md" | |
languages: "Simplified-Chinese" | |
prompt: "${{ steps.prompt.outputs.prompt }}" | |
basePath: ${{ secrets.BASE_URL }} |