-
Notifications
You must be signed in to change notification settings - Fork 6
66 lines (66 loc) · 2.5 KB
/
i18n-download.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
name: I18n Dictionary Download
on:
repository_dispatch:
types:
- simplelocalize_publication
jobs:
download-and-apply:
name: Dictionary Download
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v4
with:
ref: main
- 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: Set up Node
uses: actions/setup-node@v4
with:
node-version: 21
- name: Install dependencies
run: npm ci
- name: Format files
run: npm run format
- name: Check the change stats
id: stats
run: |
changes="$(git diff --name-only | jq --raw-input --slurp 'split("\n") | map(select(length>0))' --compact-output)"
echo "change-count=$(echo $changes | jq --raw-output 'length')" >> $GITHUB_OUTPUT
- 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: Close the old pull requests
if: ${{ steps.stats.outputs.change-count >= 1 }}
run: |
for number in `gh pr list --author "github-actions[bot]" --search "head:i18n-update-" --json number | jq --raw-output 'map(.number) | join(" ")'`
do
gh pr close $number --comment "" --delete-branch
done
env:
GH_TOKEN: ${{ github.token }}
- 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." \
--reviewer axross
env:
GH_TOKEN: ${{ github.token }}