Skip to content

Download Lokalise translations #2

Download Lokalise translations

Download Lokalise translations #2

name: Download Lokalise translations
on:
schedule:
- cron: "0 2 * * 1"
jobs:
build:
if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.workflow_run.head_branch }}
fetch-depth: 0
- run: git branch
- run: env
- name: Lokalise CLI
run: curl -sfL https://raw.githubusercontent.com/lokalise/lokalise-cli-2-go/master/install.sh | sh
- name: Pull
env:
VAR_LOKALISE_API_TOKEN: ${{ secrets.LOKALISE_RO_API_TOKEN }}
VAR_LOKALISE_PROJECT_ID: ${{ secrets.LOKALISE_PROJECT_ID }}
run: |
./bin/lokalise2 --token ${{ env.VAR_LOKALISE_API_TOKEN }} --project-id ${{ env.VAR_LOKALISE_PROJECT_ID }} file download --format json --export-empty-as skip --export-sort first_added --placeholder-format printf --plural-format array --indentation 4sp --directory-prefix src/translations
- name: Create Pull Request
env:
GH_TOKEN: ${{ github.token }}
GITHUB_NEW_BRANCH_NAME: Lokalise-${{ github.run_id }}${{ github.run_attempt }}
run: |
git checkout -b ${{ env.GITHUB_NEW_BRANCH_NAME }}
git config --global user.name "${GITHUB_ACTOR}"
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git add ./\*.json
if [[ -z $(git status --untracked-files=no --porcelain) ]]
then
echo "No changes"
else
git commit -m 'Translations update'
git push --set-upstream origin ${{ env.GITHUB_NEW_BRANCH_NAME }}
gh pr create --base main --head ${{ env.GITHUB_NEW_BRANCH_NAME }} --title "Lokalise translations update" --body ""
fi