Language File Download and Compare Docker
This Docker container downloads language JSON files from a specified URL, compares them with existing files, and automatically commits and pushes changes to a Git repository.
Features
- Downloads language files for multiple languages
- Compares new files with existing ones
- Generates diff files for changes
- Automatically commits and pushes changes to Git
- Supports 15 languages: en, zh-TW, ja, ko, fr, de, es, it, nl, pl, pt, ru, tr, vi, zh-CN
Setup
-
Copy
env.exampleto.envand configure your Git repository:cp env.example .env -
Edit
.envwith your Git repository details and authentication method:Method 1: Personal Access Token (Recommended)
GIT_REPO_URL=https://github.com/yourusername/yourrepo.git GIT_USERNAME=yourusername GIT_EMAIL=your.email@example.com GIT_BRANCH=main GITHUB_TOKEN=ghp_your_personal_access_token_hereMethod 2: SSH Key
GIT_REPO_URL=git@github.com:yourusername/yourrepo.git GIT_USERNAME=yourusername GIT_EMAIL=your.email@example.com GIT_BRANCH=main -
Build and run the container:
docker-compose up --build
GitHub Authentication
Personal Access Token (Recommended)
- Go to GitHub → Settings → Developer settings → Personal access tokens
- Generate a new token with
reposcope - Add the token to your
.envfile asGITHUB_TOKEN - Use HTTPS URLs:
https://github.com/username/repo.git
SSH Key Authentication
- Generate SSH key pair:
ssh-keygen -t ed25519 -C "your_email@example.com" - Add public key to GitHub → Settings → SSH and GPG keys
- Use SSH URLs:
git@github.com:username/repo.git - Mount your private key in docker-compose (see Advanced Configuration)
Local Testing
For local testing on your machine:
-
Install dependencies:
pip install -r requirements.txt -
Create a
.envfile with your Git configuration (same as above) -
Run the script locally:
python download_and_compare.py
The script will automatically load environment variables from the .env file using python-dotenv.
Usage
The container will:
- Download language files from the configured URL
- Compare with existing files
- Generate diff files for any changes
- Commit and push changes to the Git repository
Files Generated
{lang}.json- Current language files{lang}.diff- Diff files showing changes (only when changes detected)
Environment Variables
GIT_REPO_URL- URL of the Git repository to push toGIT_USERNAME- Git username for commitsGIT_EMAIL- Git email for commitsGIT_BRANCH- Git branch to use (defaults to 'main')
Running Manually
To run the script manually outside of Docker:
python download_and_compare.py
The script will automatically load your .env file for local testing.