Skip to content

Commit

Permalink
Add new workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
ilxlodev authored Sep 15, 2024
1 parent a64846e commit 59eaa99
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 0 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/clean-orphaned-files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Clean up orphaned translation files
on:
workflow_dispatch:
jobs:
clean_orphaned_files:
name: Clean up orphaned files
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 2

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "14"

- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install --no-package-lock

- name: Cache jq
id: cache-jq
uses: actions/cache@v3
with:
path: /usr/local/bin/jq
key: ${{ runner.os }}-jq
restore-keys: |
${{ runner.os }}-jq
- name: Install jq (JSON processor)
if: steps.cache-jq.outputs.cache-hit != 'true'
uses: dcarbone/install-jq-action@main

- name: Clean orphaned JSON files from other languages
run: |
for lang_dir in $(find . -mindepth 1 -maxdepth 1 -type d -name "*-*" | grep -E '[a-z]{2}-[A-Z]{2}'); do
lang=$(basename "$lang_dir")
find "$lang_dir" -type f -name "*.json" | while read file; do
en_us_file="${file/$lang/en-US}"
if [ ! -f "$en_us_file" ]; then
rm "$file"
echo "Deleted orphaned file $file in $lang"
fi
done
done
- name: Commit changes
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add .
git diff-index --quiet HEAD || git commit -m "Clean up orphaned translation files"
- name: Create a pull request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Clean up orphaned translation files"
branch: "auto/clean-orphaned-files-${{ github.ref_name }}"
title: "Clean up orphaned translation files in ${{ github.ref_name }}"
body: "This PR cleans up orphaned translation files for the branch **${{ github.ref_name }}**."
assignees: ilxlodev
reviewers: ilxlodev
labels: cleanup, blocked
base: ${{ github.ref_name }}
61 changes: 61 additions & 0 deletions .github/workflows/sync-translations.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Sync translations to other languages
on:
push:
paths:
- "en-US/**.json"
branches:
- "**/stable"
workflow_dispatch:
jobs:
sync_translations:
name: Sync translations
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: "14"
- name: Cache Node.js modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install
- name: Install jq (JSON processor)
uses: dcarbone/install-jq-action@main
- name: Copy new JSON files to other languages
run: |
for lang_dir in $(find . -mindepth 1 -maxdepth 1 -type d -name "*-*" | grep -E '[a-z]{2}-[A-Z]{2}'); do
lang=$(basename "$lang_dir")
find en-US -type f -name "*.json" | while read file; do
new_file="${file/en-US/$lang}"
if [ ! -f "$new_file" ]; then
mkdir -p "$(dirname "$new_file")"
cp "$file" "$new_file"
echo "Created $new_file in $lang"
fi
done
done
- name: Commit changes
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add .
git commit -m "Add new translation files for other languages"
- name: Create a pull request
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
commit-message: "Add new translation files for other languages"
branch: "auto/sync-translations-${{ github.ref_name }}"
title: "Sync translations in ${{ github.ref_name }}"
body: "This PR adds new translation files for the branch **${{ github.ref_name }}**."
assignees: ilxlodev
reviewers: ilxlodev
labels: syncronization, blocked
base: ${{ github.ref_name }}

0 comments on commit 59eaa99

Please sign in to comment.