From 6c3343664068ddd971902c183ad7d3a30717ae8a Mon Sep 17 00:00:00 2001 From: Oliver Hamlet Date: Sat, 6 Jul 2024 14:16:50 +0100 Subject: [PATCH] Add workflow to export prelude translations The workflow runs for pull requests that modify prelude.yaml, and the export job runs if it's possible to modify the PR. --- .github/workflows/export-translations.yml | 47 +++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/export-translations.yml diff --git a/.github/workflows/export-translations.yml b/.github/workflows/export-translations.yml new file mode 100644 index 0000000..352a95b --- /dev/null +++ b/.github/workflows/export-translations.yml @@ -0,0 +1,47 @@ +name: Export translations from prelude + +on: + pull_request: + paths: [prelude.yaml] + +jobs: + export: + runs-on: ubuntu-20.04 + + # Don't run this for the Weblate bot user as it already exports after import. + if: ${{ github.event.sender.id != 1607653 && github.event.pull_request.maintainer_can_modify == true }} + + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v5 + with: + python-version: '3.10' + + - name: Install dependencies + run: | + python -m venv .venv + ./.venv/bin/activate + pip install -r requirements.txt + + - name: Run the export translations script + run: python scripts/export-translations.py + + - name: Create patch containing changes + run: git diff > sync-translations.patch + + - name: Record pull request head data + run: | + echo 'export PR_HEAD_URL="${{ github.event.pull_request.head.repo.clone_url }}"' > git_vars.sh + echo 'export PR_HEAD_REF="${{ github.event.pull_request.head.ref }}"' >> git_vars.sh + echo 'export COMMIT_MESSAGE="Export translations from prelude"' >> git_vars.sh + + - name: Upload data + uses: actions/upload-artifact@v4 + with: + name: sync-translations-data + path: | + sync-translations.patch + git_vars.sh