This repository has been archived by the owner on Jan 20, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: github action composite * docs: update information about composite
- Loading branch information
Showing
4 changed files
with
116 additions
and
3 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# GitHub Action `> Nested JSON Postprocessor` | ||
|
||
Remove null or empty keys, list and array from JSON files. | ||
|
||
## `> Postprocessor // Usage` | ||
|
||
Before you start, make sure that you have setup the supported version of Python in your workflow: | ||
|
||
| Python version | Support status | | ||
| -------------- | ---------------- | | ||
| Upcoming | ⚙️ Best effort | | ||
| 3.12 | ✅ Supported | | ||
| 3.11 | ✅ Supported | | ||
| 3.10 | ✅ Supported | | ||
| 3.9 | ✅ Supported | | ||
| 3.8 | ⚙️ Best effort | | ||
| 3.7 | ⚙️ Best effort | | ||
| =<3.6 | ❌ Not Supported | | ||
|
||
```yml | ||
- name: Set up Python 3.12 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.12 | ||
``` | ||
| Input | Required | Description | | ||
| ---------------------- | ----------------------------------- | ------------------ | | ||
| `source_dir` | ✅ Yes | Input directory | | ||
| `destination_dir` | ❌ No (default to `source_dir`) | Output directory | | ||
| `signing_key` | ❌ No | Signing key | | ||
| `commit_message` | ❌ No (default to `JSON Cleanup`) | Commit message | | ||
| `secrets.GITHUB_TOKEN` | ❌ No (default to GitHub's default) | GitHub's PAT token | | ||
|
||
```yml | ||
- name: Nested JSON Postprocessor | ||
uses: ./.github/actions/python-action ???? # Soon:tm: | ||
with: | ||
source_dir: 'path/to/your/source/directory' # required, your input directory | ||
destination_dir: 'path/to/your/destination/directory' # optional, default to source_dir | ||
signing_key: 'your-signing-key' # optional, will skip signing if not provided | ||
commit_message: 'your-custom-commit-message' # optional, default to "JSON Cleanup" | ||
secrets: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # optional, default to GitHub's default | ||
``` |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
name: "Crowdin Nested JSON Postprocessor" | ||
description: "Runs a Python script that remove empty string in JSON caused by Crowdin not respecting skip untranslated strings" | ||
|
||
inputs: | ||
source_dir: | ||
description: "The source directory to copy" | ||
required: true | ||
destination_dir: | ||
description: "The destination directory (optional)" | ||
required: false | ||
signing_key: | ||
description: "The GPG key to sign commits (optional)" | ||
required: false | ||
commit_message: | ||
description: "Commit message (optional)" | ||
required: false | ||
default: "JSON Cleanup" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setup directories and copy files | ||
run: | | ||
mkdir -p input output | ||
cp -r "${{ inputs.source_dir }}"/* input/ | ||
if [[ -n "${{ inputs.destination_dir }}" ]]; then | ||
DESTINATION_DIR="${{ inputs.destination_dir }}" | ||
else | ||
DESTINATION_DIR=input | ||
fi | ||
shell: bash | ||
|
||
- name: Run Python script | ||
run: python3 main.py | ||
shell: bash | ||
|
||
- name: Copy output files | ||
run: | | ||
cp -r output/* "$DESTINATION_DIR/" | ||
shell: bash | ||
|
||
- name: Commit changes | ||
run: | | ||
echo "Committing changes..." | ||
if [[ -n "${{ inputs.signing_key }}" ]]; then | ||
git config --global user.signingkey "${{ inputs.signing_key }}" | ||
git config --global commit.gpgsign true | ||
COMMIT_OPTIONS="-S" | ||
else | ||
COMMIT_OPTIONS="" | ||
fi | ||
echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token | ||
git add . | ||
git commit $COMMIT_OPTIONS -m ${{ inputs.commit_message }} | ||
git push | ||
shell: bash |