Skip to content

feat(py#strands-agent): add AG-UI protocol support with CopilotKit React connection #688

feat(py#strands-agent): add AG-UI protocol support with CopilotKit React connection

feat(py#strands-agent): add AG-UI protocol support with CopilotKit React connection #688

name: Translate Documentation
on:
pull_request:
paths:
- 'docs/src/content/docs/en/**/*.md'
- 'docs/src/content/docs/en/**/*.mdx'
- 'packages/nx-plugin/src/**/schema.json'
workflow_dispatch:
inputs:
full_translation:
description: 'Run full translation of all docs'
type: boolean
default: false
languages:
description: 'Target languages (comma-separated)'
type: string
default: 'jp,ko,es,pt,fr,it,zh,vi'
required: true
permissions:
id-token: write # Required for OIDC
contents: write # Required for committing changes
pull-requests: write # Required for updating PR
jobs:
translate:
name: Translate Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v6
with:
ref: ${{ github.head_ref }} # Explicitly checkout the PR branch
fetch-depth: 0 # Required to detect changed files
token: ${{ secrets.TRANSLATE_PUSH_GITHUB_TOKEN }} # needed to trigger PR workflow after push
- uses: ./.github/actions/init-monorepo
with:
aws-docker-login-role-arn: ${{ secrets.AWS_DOCKER_LOGIN_ROLE_ARN }}
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v6
with:
role-to-assume: ${{ secrets.AWS_TRANSLATE_ROLE_ARN }}
aws-region: ${{ secrets.AWS_TRANSLATE_AWS_REGION || 'us-west-2' }}
- name: Run translation
id: translate
run: |
TRANSLATION_ARGS=""
# Check if this is a workflow dispatch with full translation
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.full_translation }}" == "true" ]]; then
TRANSLATION_ARGS="--all"
echo "Running full translation"
else
echo "Running translation for changed files only"
fi
# Set target languages
if [[ "${{ github.event_name }}" == "workflow_dispatch" && "${{ github.event.inputs.languages }}" != "" ]]; then
TRANSLATION_ARGS="$TRANSLATION_ARGS --languages ${{ github.event.inputs.languages }}"
fi
# Run the translation script
pnpm tsx ./scripts/translate.ts $TRANSLATION_ARGS --verbose
# Check if any files were changed
if [[ -n "$(git status --porcelain)" ]]; then
echo "has_changes=true" >> $GITHUB_OUTPUT
else
echo "has_changes=false" >> $GITHUB_OUTPUT
fi
- name: Commit translations
id: commit_translations
if: steps.translate.outputs.has_changes == 'true'
run: |
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
# Add and commit changes
git add docs/src/content/docs/ docs/src/i18n/schema-translations.json
git commit -m "docs: update translations" --no-verify
# Push directly to the PR branch
git push origin HEAD:${{ github.head_ref }}
- name: Update PR
if: github.event_name == 'pull_request' && steps.translate.outputs.has_changes == 'true'
env:
URL: ${{ github.event.pull_request.comments_url}}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
FILES_CHANGED=$(git diff --name-only HEAD^ | xargs -I{} bash -c 'echo -n "\n{}";')
LATEST_COMMIT=$(git log --pretty=format:"%h" -n 1)
# Use GitHub API to create a comment
curl -X POST "$URL" \
-H "Content-Type: application/json" \
-H "Authorization: token $GITHUB_TOKEN" \
-d "{\"body\":\"📚 Documentation translations have been updated and committed ($LATEST_COMMIT) to this PR.\n\n\`\`\`$FILES_CHANGED\n\`\`\`\"}"