Check Proxies #2868
This file contains hidden or 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
| name: Check Proxies | |
| # Trigger workflow | |
| on: | |
| schedule: | |
| # Run at minute 0 of every hour | |
| - cron: '0 * * * *' | |
| workflow_dispatch: # Allow manual trigger | |
| # Permissions (top-level fallback) | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: check-proxies | |
| cancel-in-progress: false | |
| jobs: | |
| check-proxies: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| # Checkout repository with full history | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 1 | |
| persist-credentials: false | |
| - name: Configure Git user | |
| run: | | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # Set up Python | |
| - name: Set up Python | |
| uses: actions/setup-python@v4 | |
| with: | |
| python-version: '3.13' | |
| # Install dependencies | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install tqdm | |
| pip install aiohttp | |
| pip install aioping | |
| pip install geoip2 | |
| pip install pyyaml | |
| pip install ruamel.yaml | |
| pip install requests | |
| # Install Xray core | |
| - name: Install Xray core | |
| run: | | |
| # Download and install Xray (extract to isolated directory to avoid overwrite prompts) | |
| wget -q https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-64.zip | |
| mkdir -p xray-dist | |
| unzip -q -n Xray-linux-64.zip -d xray-dist | |
| chmod +x xray-dist/xray | |
| sudo mv xray-dist/xray /usr/local/bin/ | |
| rm -rf xray-dist Xray-linux-64.zip | |
| # Verify installation | |
| xray version | |
| # Run proxy checker script for proxies | |
| - name: Run proxies checker | |
| env: | |
| OPENRAY_RECHECK_EXISTING: "1" | |
| run: python -m src.main | |
| # Reset tested state if proxy count is below threshold | |
| - name: Reset tested state when proxy count < 500 | |
| run: | | |
| COUNT=$(wc -l < ./output/all_valid_proxies.txt 2>/dev/null || echo 0) | |
| echo "Detected proxy count: $COUNT" | |
| if [ "$COUNT" -lt 500 ]; then | |
| echo "Proxy count below 500. Removing tested state files (text and binary)." | |
| rm -f .state/tested.txt .state/tested*.txt .state/tested*.txt.bin | |
| else | |
| echo "Proxy count >= 500. Keeping tested state files." | |
| fi | |
| # Run the converter scripts | |
| - name: Convert proxy lists to Clash and Singbox formats | |
| run: | | |
| # Convert main proxy list | |
| python src/converter/sub2clash_singbox.py \ | |
| ./output/all_valid_proxies.txt \ | |
| src/converter/config.yaml \ | |
| src/converter/singbox.json \ | |
| ./output/converted/all_valid_proxies_clash_config.yaml \ | |
| ./output/converted/all_valid_proxies_singbox_config.json | |
| # Convert Iran top100 proxy list | |
| python src/converter/sub2clash_singbox.py \ | |
| ./output_iran/iran_top100_checked.txt \ | |
| src/converter/config.yaml \ | |
| src/converter/singbox.json \ | |
| ./output_iran/converted/iran_top100_clash_config.yaml \ | |
| ./output_iran/converted/iran_top100_singbox_config.json | |
| # Convert Irancell top100 proxy list | |
| python src/converter/sub2clash_singbox.py \ | |
| ./output_iran/irancell_top100.txt \ | |
| src/converter/config.yaml \ | |
| src/converter/singbox.json \ | |
| ./output_iran/converted/irancell_top100_clash_config.yaml \ | |
| ./output_iran/converted/irancell_top100_singbox_config.json | |
| # Convert MCI top100 proxy list | |
| python src/converter/sub2clash_singbox.py \ | |
| ./output_iran/mci_top100.txt \ | |
| src/converter/config.yaml \ | |
| src/converter/singbox.json \ | |
| ./output_iran/converted/mci_top100_clash_config.yaml \ | |
| ./output_iran/converted/mci_top100_singbox_config.json | |
| # Convert TCI top100 proxy list | |
| python src/converter/sub2clash_singbox.py \ | |
| ./output_iran/tci_top100.txt \ | |
| src/converter/config.yaml \ | |
| src/converter/singbox.json \ | |
| ./output_iran/converted/tci_top100_clash_config.yaml \ | |
| ./output_iran/converted/tci_top100_singbox_config.json | |
| # Convert Others top100 proxy list | |
| python src/converter/sub2clash_singbox.py \ | |
| ./output_iran/others_top100.txt \ | |
| src/converter/config.yaml \ | |
| src/converter/singbox.json \ | |
| ./output_iran/converted/others_top100_clash_config.yaml \ | |
| ./output_iran/converted/others_top100_singbox_config.json | |
| # Commit and push changes directly to the main | |
| - name: Commit and push changes (no rebase, ignore conflicts) | |
| run: | | |
| # Fetch latest main | |
| git fetch origin main | |
| # Try merge without rebase | |
| if ! git merge origin/main --no-edit; then | |
| echo "⚠️ Merge conflict detected. Discarding local changes..." | |
| git merge --abort || true | |
| git reset --hard origin/main | |
| exit 0 | |
| fi | |
| # Add files | |
| git add .state/ output/ output_iran/ | |
| # Commit only if there are changes | |
| if ! git diff --cached --quiet; then | |
| git commit -m "Update proxy lists [skip ci]" | |
| git push https://x-access-token:${{ secrets.PERSONAL_TOKEN }}@github.com/${{ github.repository }}.git main | |
| else | |
| echo "No changes to commit." | |
| fi |