Skip to content

Commit b210a3f

Browse files
authored
Add gh workflow for creating translations PR (#772)
* Add gh workflow for creating translations PR * Update workflow name
1 parent 3544e87 commit b210a3f

File tree

1 file changed

+56
-0
lines changed

1 file changed

+56
-0
lines changed
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Create Translations PR
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
language_code:
7+
description: 'Crowdin language code for the language of interest'
8+
required: true
9+
10+
jobs:
11+
create-translations-pr:
12+
runs-on: ubuntu-latest
13+
# Run only on main branch in upstream repo.
14+
if: ${{ github.repository == 'numpy/numpy.org' && github.ref == 'refs/heads/main' }}
15+
steps:
16+
- name: Checkout numpy.org
17+
uses: actions/checkout@v4
18+
with:
19+
repository: 'numpy/numpy.org'
20+
path: 'numpy.org'
21+
ref: 'main'
22+
fetch-depth: 0 # Gets full github history.
23+
# Full history is needed for the scripted interactive rebase
24+
# which takes place in create_branch_for_language.sh below.
25+
26+
- name: Checkout scientific-python-translations automations
27+
uses: actions/checkout@v4
28+
with:
29+
repository: 'scientific-python-translations/automations'
30+
path: 'automations'
31+
ref: 'main'
32+
33+
- name: Create translations branch for language of interest
34+
env:
35+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
36+
run: |
37+
git config --global user.email "[email protected]"
38+
git config --global user.name "GitHub Actions"
39+
../automations/scripts/create_branch_for_language.sh origin main l10n_main ${{ github.event.inputs.language_code }}
40+
branch_name=$(git rev-parse --abbrev-ref HEAD)
41+
git push -u origin $branch_name
42+
echo "BRANCH_NAME=$branch_name" >> $GITHUB_ENV
43+
working-directory: ./numpy.org
44+
45+
- name: Create Pull Request
46+
env:
47+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
48+
run: |
49+
language_name=$(../automations/scripts/get_language_name.sh ${{ github.event.inputs.language_code }})
50+
gh pr create --base main --head ${{ env.BRANCH_NAME }} --title "Update translations for $language_name" \
51+
--body "This PR to update translations for $language_name was generated by the GitHub workflow, \
52+
auto-translations-pr.yml and includes all commits from this repo's Crowdin branch for the language \
53+
of interest. A final check of the rendered docs is needed to identify if there are any formatting \
54+
errors due to incorrect string segmentation by Crowdin. If there are such formatting errors, they \
55+
should be fixed directly on this branch, not through Crowdin."
56+
working-directory: ./numpy.org

0 commit comments

Comments
 (0)