Cron Task #1002
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: Cron Task | |
| on: | |
| schedule: | |
| - cron: "15 0/24 * * *" # 每天 UTC 00:15 执行一次 | |
| push: | |
| branches: [ "main" ] | |
| pull_request: | |
| branches: [ "main" ] | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: cron-task | |
| cancel-in-progress: true | |
| jobs: | |
| build: | |
| name: Build and Update Rules | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 📥 Checkout current repository | |
| uses: actions/checkout@v6 | |
| - name: 📥 Checkout v2fly/domain-list-community | |
| uses: actions/checkout@v6 | |
| with: | |
| repository: v2fly/domain-list-community | |
| path: v2fly-dataset | |
| - name: ⚙️ Set up Go 1.25 | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: "1.25" | |
| cache: true | |
| - name: 🐍 Set up Python 3.13 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.13" | |
| - name: 📦 Create virtualenv and define PYTHON_EXEC | |
| shell: bash | |
| run: | | |
| python -m venv venv | |
| if [ -x "venv/bin/python" ]; then | |
| echo "PYTHON_EXEC=$(pwd)/venv/bin/python" >> $GITHUB_ENV | |
| else | |
| echo "PYTHON_EXEC=$(pwd)/venv/Scripts/python.exe" >> $GITHUB_ENV | |
| fi | |
| - name: 📚 Install Python dependencies | |
| shell: bash | |
| run: | | |
| $PYTHON_EXEC -m pip install -q httpx pandas maxminddb | |
| - name: 🧱 Generate domain rules using Go | |
| shell: bash | |
| run: | | |
| cd v2fly-dataset | |
| go run ./ -exportlists "category-ads-all,cn,geolocation-!cn" -outputdir $GITHUB_WORKSPACE | |
| - name: 🧪 Run post-processing Python scripts | |
| shell: bash | |
| env: | |
| IPLOCATE_API_KEY: ${{ secrets.IPLOCATE_API_KEY }} | |
| run: | | |
| $PYTHON_EXEC .github/scripts/setup_adguard.py | |
| $PYTHON_EXEC .github/scripts/setup_v2fly.py | |
| $PYTHON_EXEC .github/scripts/setup_asn.py | |
| $PYTHON_EXEC .github/scripts/setup_asn_v2.py | |
| - name: ⬆️ Commit and push if changes | |
| shell: bash | |
| run: | | |
| git config --local user.name "github-actions[bot]" | |
| git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| git add ruleset-*.conf || true | |
| if git diff --cached --quiet; then | |
| echo "✅ No changes to ruleset-*.conf. Skipping commit." | |
| else | |
| git commit -m "ci: auto-build" | |
| git push | |
| fi |