Skip to content

Add gh workflow for creating translations PR #772

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions .github/workflows/create-translations-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Create Translations PR

on:
workflow_dispatch:
inputs:
language_code:
description: 'Crowdin language code for the language of interest'
required: true

jobs:
create-translations-pr:
runs-on: ubuntu-latest
# Run only on main branch in upstream repo.
if: ${{ github.repository == 'numpy/numpy.org' && github.ref == 'refs/heads/main' }}
steps:
- name: Checkout numpy.org
uses: actions/checkout@v4
with:
repository: 'numpy/numpy.org'
path: 'numpy.org'
ref: 'main'
fetch-depth: 0 # Gets full github history.
# Full history is needed for the scripted interactive rebase
# which takes place in create_branch_for_language.sh below.

- name: Checkout scientific-python-translations automations
uses: actions/checkout@v4
with:
repository: 'scientific-python-translations/automations'
path: 'automations'
ref: 'main'

- name: Create translations branch for language of interest
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "[email protected]"
git config --global user.name "GitHub Actions"
../automations/scripts/create_branch_for_language.sh origin main l10n_main ${{ github.event.inputs.language_code }}
branch_name=$(git rev-parse --abbrev-ref HEAD)
git push -u origin $branch_name
echo "BRANCH_NAME=$branch_name" >> $GITHUB_ENV
working-directory: ./numpy.org

- name: Create Pull Request
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
language_name=$(../automations/scripts/get_language_name.sh ${{ github.event.inputs.language_code }})
gh pr create --base main --head ${{ env.BRANCH_NAME }} --title "Update translations for $language_name" \
--body "This PR to update translations for $language_name was generated by the GitHub workflow, \
auto-translations-pr.yml and includes all commits from this repo's Crowdin branch for the language \
of interest. A final check of the rendered docs is needed to identify if there are any formatting \
errors due to incorrect string segmentation by Crowdin. If there are such formatting errors, they \
should be fixed directly on this branch, not through Crowdin."
working-directory: ./numpy.org