From 4bab730795a18921cfd25e9539d97bd1aec928b4 Mon Sep 17 00:00:00 2001 From: Marek Blaha Date: Wed, 8 Nov 2023 09:55:06 +0100 Subject: [PATCH] Workflow for *.po retrieval from weblate --- .github/workflows/weblate-sync-po.yml | 67 +++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 .github/workflows/weblate-sync-po.yml diff --git a/.github/workflows/weblate-sync-po.yml b/.github/workflows/weblate-sync-po.yml new file mode 100644 index 000000000..2d9f76c72 --- /dev/null +++ b/.github/workflows/weblate-sync-po.yml @@ -0,0 +1,67 @@ +name: Weblate - retrieve translations +on: + schedule: + # Run every monday morning + - cron: '30 3 * * 1' + workflow_dispatch: + +jobs: + po-refresh: + name: Retrieve *.po files from dnf5-l10n repository + environment: self + permissions: + pull-requests: write + statuses: write + runs-on: ubuntu-latest + steps: + - name: Clone source repository + uses: actions/checkout@v4 + with: + ssh-key: ${{ secrets.L10N_SSH_KEY }} + path: src + + - name: Clone weblate repository + uses: actions/checkout@v4 + with: + repository: ${{ github.repository }}-l10n + path: l10n + + - name: Get branche name + id: branch-name + run: echo "BRANCH_NAME=weblate-sync-$(date +"%Y-%m-%d-%H-%M-%S")" >> $GITHUB_OUTPUT + + - name: Prepare a new branch + run: git -C src checkout -b ${{ steps.branch-name.outputs.BRANCH_NAME }} + + - name: Copy .po files from weblate repository + run: | + echo "================" + cat src/.git/config + echo "================" + pushd l10n + for component in $(find . -mindepth 1 -maxdepth 1 -type d -not -path './.*'); do + source_path="" + if [ -f "${component}/PATH" ]; then + read -r source_path < "${component}/PATH" + for po in "${component}"/*.po; do + if [ -f "$po" ]; then + cp "${po}" "../src/${source_path}/" + fi + done + fi + done + popd + + - name: Create a pull request + env: + GH_TOKEN: ${{ github.token }} + run: | + git config --global user.name "GitHub Workflow" + git config --global user.email "mblaha@redhat.com" + pushd src + git add "*" + git commit -m "Update translations from Fedora Weblate" + #git push origin ${{ steps.branch-name.outputs.BRANCH_NAME }} + #gh pr create -B main --head ${{ steps.branch-name.outputs.BRANCH_NAME }} --title 'Update translations from Fedora Weblate' --body 'Created by Github action' + gh pr create --title 'Update translations from Fedora Weblate' --body 'Created by Github action' + popd