From 6d7ff86f964bbbe834db6ae77d52db41087218bf Mon Sep 17 00:00:00 2001 From: steppi Date: Sat, 31 Aug 2024 11:33:08 -0400 Subject: [PATCH 1/2] Add gh workflow for creating translations PR --- .github/workflows/create-translations-pr.yml | 56 ++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/create-translations-pr.yml diff --git a/.github/workflows/create-translations-pr.yml b/.github/workflows/create-translations-pr.yml new file mode 100644 index 0000000000..96eabb29db --- /dev/null +++ b/.github/workflows/create-translations-pr.yml @@ -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: + auto-translation-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 "actions@github.com" + 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 From db819c72be63a0d258e66c04bac2853a3bf166d8 Mon Sep 17 00:00:00 2001 From: steppi Date: Sat, 31 Aug 2024 11:40:36 -0400 Subject: [PATCH 2/2] Update workflow name --- .github/workflows/create-translations-pr.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/create-translations-pr.yml b/.github/workflows/create-translations-pr.yml index 96eabb29db..3804511d42 100644 --- a/.github/workflows/create-translations-pr.yml +++ b/.github/workflows/create-translations-pr.yml @@ -8,7 +8,7 @@ on: required: true jobs: - auto-translation-pr: + 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' }}