docs(blog): publish GPU sharing guide for Kubernetes #26
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: Translate new posts to English | |
| on: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'src/content/blog/**/*.md' | |
| permissions: | |
| contents: write | |
| jobs: | |
| translate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout main branch | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 2 | |
| - name: Get changed blog posts | |
| id: changes | |
| run: | | |
| POSTS=$(git diff --name-only HEAD~1 HEAD -- 'src/content/blog/*.md') | |
| if [ -n "$POSTS" ]; then | |
| echo "has_posts=true" >> $GITHUB_OUTPUT | |
| echo "Changed posts:" | |
| echo "$POSTS" | |
| else | |
| echo "has_posts=false" >> $GITHUB_OUTPUT | |
| echo "No changed posts" | |
| fi | |
| - name: Set ONLY_FILES env | |
| if: steps.changes.outputs.has_posts == 'true' | |
| run: | | |
| echo 'ONLY_FILES<<EOF' >> $GITHUB_ENV | |
| git diff --name-only HEAD~1 HEAD -- 'src/content/blog/*.md' >> $GITHUB_ENV | |
| echo 'EOF' >> $GITHUB_ENV | |
| - name: Set up Python | |
| if: steps.changes.outputs.has_posts == 'true' | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| if: steps.changes.outputs.has_posts == 'true' | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install openai PyYAML python-frontmatter | |
| - name: Generate English translations | |
| if: steps.changes.outputs.has_posts == 'true' | |
| env: | |
| OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | |
| TRANSLATION_MODEL: ${{ vars.TRANSLATION_MODEL }} | |
| run: | | |
| python scripts/translate_to_en.py | |
| - name: Commit and push translations | |
| if: steps.changes.outputs.has_posts == 'true' | |
| uses: stefanzweifel/git-auto-commit-action@v5 | |
| with: | |
| commit_message: "chore: add English translations" | |
| file_pattern: 'src/content/blog-en/*.md' | |
| add_options: '-A' |