mirror of
https://github.com/hay-kot/mealie.git
synced 2025-07-05 20:42:23 -07:00
103 lines
3.1 KiB
YAML
103 lines
3.1 KiB
YAML
name: Automatic Locale Sync
|
|
|
|
on:
|
|
schedule:
|
|
# Run every Sunday at 2 AM UTC
|
|
- cron: '0 2 * * 0'
|
|
workflow_dispatch:
|
|
# Allow manual triggering from the GitHub UI
|
|
|
|
jobs:
|
|
sync-locales:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v4
|
|
with:
|
|
token: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: Set up Python
|
|
uses: actions/setup-python@v5
|
|
with:
|
|
python-version: '3.12'
|
|
|
|
- name: Install Poetry
|
|
uses: snok/install-poetry@v1
|
|
with:
|
|
virtualenvs-create: true
|
|
virtualenvs-in-project: true
|
|
|
|
- name: Load cached venv
|
|
id: cached-poetry-dependencies
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .venv
|
|
key: venv-${{ runner.os }}-${{ hashFiles('**/poetry.lock') }}
|
|
|
|
- name: Check venv cache
|
|
id: cache-validate
|
|
if: steps.cached-poetry-dependencies.outputs.cache-hit == 'true'
|
|
run: |
|
|
echo "import fastapi;print('venv good?')" > test.py && poetry run python test.py && echo "cache-hit-success=true" >> $GITHUB_OUTPUT
|
|
rm test.py
|
|
continue-on-error: true
|
|
|
|
- name: Install dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install libsasl2-dev libldap2-dev libssl-dev
|
|
poetry install
|
|
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
|
|
|
|
- name: Run locale generation
|
|
run: |
|
|
cd dev/code-generation
|
|
poetry run python main.py locales
|
|
env:
|
|
CROWDIN_API_KEY: ${{ secrets.CROWDIN_API_KEY }}
|
|
|
|
- name: Check for changes
|
|
id: changes
|
|
run: |
|
|
if git diff --quiet; then
|
|
echo "has_changes=false" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "has_changes=true" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Commit and create PR
|
|
if: steps.changes.outputs.has_changes == 'true'
|
|
run: |
|
|
# Configure git
|
|
git config --local user.email "action@github.com"
|
|
git config --local user.name "GitHub Action"
|
|
|
|
# Create a new branch
|
|
BRANCH_NAME="auto-locale-sync-$(date +%Y%m%d-%H%M%S)"
|
|
git checkout -b "$BRANCH_NAME"
|
|
|
|
# Add and commit changes
|
|
git add .
|
|
git commit -m "chore: automatic locale sync"
|
|
|
|
# Push the branch
|
|
git push origin "$BRANCH_NAME"
|
|
|
|
# Create PR using GitHub CLI
|
|
gh pr create --title "chore: automatic locale sync" --body "## Summary
|
|
|
|
Automatically generated locale updates from the weekly sync job.
|
|
|
|
## Changes
|
|
- Updated frontend locale files
|
|
- Generated from latest translation sources
|
|
|
|
## Test plan
|
|
- [ ] Verify locale files are properly formatted
|
|
- [ ] Test that translations load correctly in the frontend" --base dev --head "$BRANCH_NAME"
|
|
env:
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
- name: No changes detected
|
|
if: steps.changes.outputs.has_changes == 'false'
|
|
run: echo "No locale changes detected, skipping PR creation"
|