Download Lokalise translations #6
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Download Lokalise translations | |
on: | |
schedule: | |
- cron: "0 2 * * 2" | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- 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 |