This commit is contained in:
Yorgei
2025-08-30 20:11:34 +10:00
commit 867ece014a
8 changed files with 317 additions and 0 deletions

103
README.md Normal file
View File

@@ -0,0 +1,103 @@
# 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
1. Copy `env.example` to `.env` and configure your Git repository:
```bash
cp env.example .env
```
2. Edit `.env` with 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_here
```
**Method 2: SSH Key**
```
GIT_REPO_URL=git@github.com:yourusername/yourrepo.git
GIT_USERNAME=yourusername
GIT_EMAIL=your.email@example.com
GIT_BRANCH=main
```
3. Build and run the container:
```bash
docker-compose up --build
```
## GitHub Authentication
### Personal Access Token (Recommended)
1. Go to GitHub → Settings → Developer settings → Personal access tokens
2. Generate a new token with `repo` scope
3. Add the token to your `.env` file as `GITHUB_TOKEN`
4. Use HTTPS URLs: `https://github.com/username/repo.git`
### SSH Key Authentication
1. Generate SSH key pair: `ssh-keygen -t ed25519 -C "your_email@example.com"`
2. Add public key to GitHub → Settings → SSH and GPG keys
3. Use SSH URLs: `git@github.com:username/repo.git`
4. Mount your private key in docker-compose (see Advanced Configuration)
## Local Testing
For local testing on your machine:
1. Install dependencies:
```bash
pip install -r requirements.txt
```
2. Create a `.env` file with your Git configuration (same as above)
3. Run the script locally:
```bash
python download_and_compare.py
```
The script will automatically load environment variables from the `.env` file using python-dotenv.
## Usage
The container will:
1. Download language files from the configured URL
2. Compare with existing files
3. Generate diff files for any changes
4. 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 to
- `GIT_USERNAME` - Git username for commits
- `GIT_EMAIL` - Git email for commits
- `GIT_BRANCH` - Git branch to use (defaults to 'main')
## Running Manually
To run the script manually outside of Docker:
```bash
python download_and_compare.py
```
The script will automatically load your `.env` file for local testing.