Skip to content

Commit 2b786f1

Browse files
committed
Update readme.md
1 parent 70a7354 commit 2b786f1

File tree

2 files changed

+77
-43
lines changed

2 files changed

+77
-43
lines changed

README.md

Lines changed: 75 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,86 @@
1-
# Hello world javascript action
1+
# SimpleLocalize GitHub Action
2+
3+
Action installs, configures, and runs the SimpleLocalize CLI with the version, command, and arguments of your choice.
4+
5+
Learn more: https://simplelocalize.io/docs/cli/get-started/
26

3-
This action prints "Hello World" or "Hello" + the name of a person to greet to the log.
47

58
## Inputs
69

7-
### `who-to-greet`
10+
### `api-key`
11+
12+
The API key for SimpleLocalize. Default `""`.
13+
14+
Example: `${{ secrets.SIMPLELOCALIZE_API_KEY }}`
15+
16+
### `command`
17+
18+
**Required** The name of command to run. Default `"status"`.
819

9-
**Required** The name of the person to greet. Default `"World"`.
20+
Example: `upload`, `auto-translate`, `download`, `publish`, `pull`
1021

11-
## Outputs
22+
### `cli-version`
1223

13-
### `time`
24+
**Required** The version of the SimpleLocalize CLI to use.
25+
All available versions can be found here: https://github.com/simplelocalize/simplelocalize-cli/releases
1426

15-
The time we greeted you.
27+
Example: `2.2.0`
1628

17-
## Example usage
29+
### `args`
1830

19-
```yaml
20-
uses: actions/[email protected]
21-
with:
22-
who-to-greet: 'Mona the Octocat'
31+
The arguments for the command. Default `""`.
32+
33+
Example: `--uploadPath ./translations/{lang}.json --uploadFormat single-language-json --dryRun`
34+
35+
# Examples of usage
36+
37+
The workflow below will upload translations, auto-translate them,
38+
download translations, publish them and pull them to the hosting resources.
39+
40+
```yml
41+
name: 'My project'
42+
on:
43+
push:
44+
branches: [ main ]
45+
46+
jobs:
47+
build:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v3
51+
- name: Upload translations
52+
uses: simplelocalize/github-action@v1
53+
with:
54+
api-key: ${{ secrets.SIMPLELOCALIZE_API_KEY }}
55+
command: 'upload'
56+
cli-version: '2.2.0'
57+
args: '--uploadPath ./translations/{lang}.json --uploadFormat single-language-json --dryRun'
58+
- name: Auto-translate project
59+
uses: simplelocalize/github-action@v1
60+
with:
61+
api-key: ${{ secrets.SIMPLELOCALIZE_API_KEY }}
62+
command: 'auto-translate'
63+
cli-version: '2.2.0'
64+
- name: Download translations
65+
uses: simplelocalize/github-action@v1
66+
with:
67+
api-key: ${{ secrets.SIMPLELOCALIZE_API_KEY }}
68+
command: 'download'
69+
cli-version: '2.2.0'
70+
args: '--downloadPath ./translations/{lang}.json --downloadFormat single-language-json'
71+
- name: Publish translations
72+
uses: simplelocalize/github-action@v1
73+
with:
74+
api-key: ${{ secrets.SIMPLELOCALIZE_API_KEY }}
75+
command: 'publish'
76+
cli-version: '2.2.0'
77+
args: '--environment latest'
78+
- name: Pull translations
79+
uses: simplelocalize/github-action@v1
80+
with:
81+
api-key: ${{ secrets.SIMPLELOCALIZE_API_KEY }}
82+
command: 'pull'
83+
cli-version: '2.2.0'
84+
args: "--pullPath ./translation-hosting-resources/ --environment latest --filterRegex '_index.json'"
2385
```
86+

action.yml

Lines changed: 2 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,7 @@ inputs:
1616
api-key:
1717
description: 'Project API Key'
1818
required: false
19-
download-path:
20-
description: 'Where files should be downloaded, e.g.: ./i18n/messages.json, ./i18n/messages/{lang}.json, ./i18n/messages/{lang}/{ns}.json'
21-
required: false
22-
download-format:
23-
description: 'Choose a localization files format. Formats: https://simplelocalize.io/docs/general/file-formats/'
24-
required: false
25-
upload-path:
26-
description: 'Which files should be uploaded, e.g.: ./i18n/messages.json, ./i18n/messages/{lang}.json, ./i18n/messages/{lang}/{ns}.json'
27-
required: false
28-
upload-format:
29-
description: 'Choose a localization files format. Formats: https://simplelocalize.io/docs/general/file-formats/'
30-
required: false
19+
default: ''
3120
args:
3221
description: 'Custom arguments for the CLI command'
3322
required: false
@@ -45,30 +34,12 @@ runs:
4534
echo "Test SimpleLocalize"
4635
echo "command: ${{ inputs.command }}"
4736
echo "cli-version: ${{ inputs.cli-version }}"
48-
if [ -z "${{ inputs.api-key }}" ]; then
49-
echo "api-key: [empty]"
50-
else
51-
echo "api-key: [hidden]"
52-
fi
53-
echo "download-path: ${{ inputs.download-path }}"
54-
echo "download-format: ${{ inputs.download-format }}"
55-
echo "upload-path: ${{ inputs.upload-path }}"
56-
echo "upload-format: ${{ inputs.upload-format }}"
5737
echo "args: ${{ inputs.args }}"
5838
shell: bash
5939
- name: "Download SimpleLocalize CLI"
6040
run: "curl -o simplelocalize.jar https://get.simplelocalize.io/binaries/${{ inputs.cli-version }}/simplelocalize-cli-${{ inputs.cli-version }}.jar"
6141
shell: bash
6242
- name: "Execute SimpleLocalize CLI Command"
63-
run: |
64-
if [[ "${{ inputs.command }}" = "download" ]]
65-
then
66-
java -jar simplelocalize.jar ${{ inputs.command }} ${{ inputs.args }} --download-path ${{ inputs.download-path }} --download-format ${{ inputs.download-format }}
67-
elif [[ "${{ inputs.command }}" = "upload" ]]
68-
then
69-
java -jar simplelocalize.jar ${{ inputs.command }} ${{ inputs.args }} --upload-path ${{ inputs.upload-path }} --upload-format ${{ inputs.upload-format }}
70-
else
71-
java -jar simplelocalize.jar ${{ inputs.command }} ${{ inputs.args }}
72-
fi
43+
run: "java -jar simplelocalize.jar ${{ inputs.command }} ${{ inputs.args }}"
7344
shell: bash
7445

0 commit comments

Comments
 (0)