Add workflow to auto-update docs on velopack PR merges #1
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 Docs | |
| on: | |
| push: | |
| branches: [master] | |
| paths: | |
| - 'docs/**' | |
| - 'scripts/translate.mjs' | |
| - 'scripts/translate.config.json' | |
| # nav / sidebar labels are derived from these, so changes here re-translate the UI JSON | |
| - 'sidebars.ts' | |
| - 'docusaurus.config.ts' | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| id-token: write | |
| actions: write | |
| # The commit this workflow makes only touches i18n/**, which is NOT in the | |
| # trigger paths above, so it will not re-trigger itself. | |
| jobs: | |
| translate: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20' | |
| - name: Install dependencies | |
| run: npm ci | |
| # Refresh the English baseline + locale scaffolding for the navbar/sidebar UI labels. | |
| # The translate step diffs against it; scaffolding byproducts we don't own are cleaned | |
| # up by the script (see cleanupAfter in translate.config.json). | |
| - name: Scaffold UI translations | |
| run: npm run i18n:scaffold | |
| # The translate script shells out to the Claude CLI (`claude -p`); the runner doesn't | |
| # ship it. The CLI reads ANTHROPIC_API_KEY from the env automatically (set on the | |
| # Translate step below), so no `claude` login/config is needed in CI. | |
| - name: Install Claude CLI | |
| run: npm install -g @anthropic-ai/claude-code | |
| - name: Translate | |
| env: | |
| ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} | |
| run: npm run translate | |
| - name: Commit and Push | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
| git add i18n | |
| if git diff --staged --quiet; then | |
| echo "No translation changes to commit." | |
| else | |
| echo "Translation changes detected. Committing..." | |
| git commit -m "automatic translation update" | |
| git push | |
| echo "Dispatching deploy workflow..." | |
| gh workflow run deploy.yml --ref master | |
| fi |