Skip to content

chore(gha): fix donwload workflow for empty case #13

chore(gha): fix donwload workflow for empty case

chore(gha): fix donwload workflow for empty case #13

Workflow file for this run

name: I18n Dictionary Download
on:
repository_dispatch:
types:
- simplelocalize_publication
push:
branches:
- fix-download-workflow
jobs:
download-and-apply:
name: Dictionary Download
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Download dictionary files from SimpleLocalize
uses: simplelocalize/github-action-cli@v2
with:
cli-version: 2.5.1
command: download
args: --downloadFormat=single-language-json --downloadPath=./src/locales/{lang}/{ns}.json
api-key: ${{ secrets.SIMPLELOCALIZE_API_KEY }}
- name: Check the change stats
id: stats
run: |
changes="$(echo "$(git diff --name-only)" | jq --raw-input --slurp 'split("\n") | map(select(length>0))' --compact-output)"
echo "change-count=$(echo $changes | jq 'length')" >> $GITHUB_OUTPUT
echo "change-list=$(echo $changes | jq 'map("- " +.+ "\n") | join("")')" >> $GITHUB_OUTPUT
- name: Check outputs
run: |
echo ${{ steps.stats.outputs.change-count }}
echo ${{ steps.stats.outputs.change-list }}
- name: Commit the changes and pushes a feature branch
if: ${{ steps.stats.outputs.change-count }} >= 1
run: |
git config --global user.name "${{ github.actor }}"
git config --global user.email "${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com"
git switch -c i18n-update-${{ github.run_id }}
git add .
git commit -m "feat(i18n): apply i18n dictionary update(s)"
git push origin i18n-update-${{ github.run_id }}
- name: Create a pull request
if: ${{ steps.stats.outputs.change-count }} >= 1
run: |
gh pr create \
--base main \
--head i18n-update-${{ github.run_id }} \
--title "feat(i18n): apply i18n dictionary update(s)" \
--body "This pull request is created by SimpleLocalize integration.\n\n${{ steps.stats.outputs.change-list }}" \
--reviewer axross
env:
GH_TOKEN: ${{ github.token }}