Update Configs #79
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: Update Configs | |
| permissions: write-all | |
| on: | |
| schedule: | |
| - cron: '0 */24 * * *' | |
| workflow_dispatch: | |
| jobs: | |
| update: | |
| runs-on: ubuntu-latest | |
| timeout-minutes: 350 | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 # Fetch all history for proper merging | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.21' | |
| cache: true | |
| - name: Download sing-box | |
| run: | | |
| SINGBOX_VERSION=$(curl -s https://api.github.com/repos/SagerNet/sing-box/releases/latest | grep '"tag_name"' | cut -d'"' -f4 | tr -d 'v') | |
| echo "Downloading sing-box v${SINGBOX_VERSION}" | |
| wget -q "https://github.com/SagerNet/sing-box/releases/download/v${SINGBOX_VERSION}/sing-box-${SINGBOX_VERSION}-linux-amd64.tar.gz" | |
| tar -xzf "sing-box-${SINGBOX_VERSION}-linux-amd64.tar.gz" | |
| cp "sing-box-${SINGBOX_VERSION}-linux-amd64/sing-box" ./sing-box | |
| chmod +x ./sing-box | |
| rm -rf "sing-box-${SINGBOX_VERSION}-linux-amd64"* | |
| ./sing-box version | |
| - name: Build | |
| run: | | |
| export GOPROXY=https://goproxy.io,direct | |
| go mod tidy | |
| go build -ldflags="-s -w" -o aggregator main.go | |
| - name: Run | |
| run: | | |
| ulimit -n 65535 | |
| mkdir -p logs | |
| ./aggregator | |
| - name: Verify | |
| run: | | |
| echo "=== Config Output ===" | |
| ls -lh config/ | |
| ls -lh config/protocols/ 2>/dev/null || true | |
| ls -lh config/batches/v2ray/ 2>/dev/null || true | |
| ls -lh config/batches/clash/ 2>/dev/null || true | |
| ls -lh config/batches/clash_advanced/ 2>/dev/null || true | |
| if [ -f "config/all_configs.txt" ]; then | |
| echo "Total V2ray configs: $(wc -l < config/all_configs.txt)" | |
| fi | |
| if [ -f "config/clash.yaml" ]; then | |
| CLASH_COUNT=$(grep -c ' - name:' config/clash.yaml 2>/dev/null || echo 0) | |
| echo "Clash standard proxies: $CLASH_COUNT" | |
| fi | |
| if [ -f "config/clash_advanced.yaml" ]; then | |
| ADV_COUNT=$(grep -c ' - name:' config/clash_advanced.yaml 2>/dev/null || echo 0) | |
| echo "Clash advanced proxies: $ADV_COUNT" | |
| fi | |
| echo "V2ray batches: $(ls config/batches/v2ray/*.txt 2>/dev/null | wc -l)" | |
| echo "Clash standard batches: $(ls config/batches/clash/*.yaml 2>/dev/null | wc -l)" | |
| echo "Clash advanced batches: $(ls config/batches/clash_advanced/*.yaml 2>/dev/null | wc -l)" | |
| echo "=== Logs ===" | |
| ls -lh logs/ 2>/dev/null || echo "No logs directory" | |
| if ls logs/*.log 2>/dev/null | head -1 | xargs -I{} tail -30 {}; then | |
| true | |
| fi | |
| - name: Upload Validation Logs | |
| uses: actions/upload-artifact@v4 | |
| if: always() | |
| with: | |
| name: validation-logs-${{ github.run_number }} | |
| path: logs/ | |
| retention-days: 14 | |
| if-no-files-found: warn | |
| - name: Commit and Push | |
| run: | | |
| # Configure git | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| # First, pull latest changes | |
| git pull origin main --rebase --autostash | |
| # Now add and commit our changes | |
| git add config/ README.md | |
| # Only commit if there are changes | |
| if ! git diff --staged --quiet; then | |
| git commit -m "Update configs [$(date -u '+%Y-%m-%d %H:%M UTC')]" | |
| git push origin main | |
| else | |
| echo "No changes to commit" | |
| fi |