Skip to content

Auto update encrypted DNS list #42

Auto update encrypted DNS list

Auto update encrypted DNS list #42

name: Auto update encrypted DNS list
on:
schedule:
# 每天北京时间 03:37 运行(UTC 19:37)
- cron: '37 19 * * *'
workflow_dispatch:
permissions:
contents: write
jobs:
update-encrypted-dns:
if: github.repository == 'Aethersailor/Custom_OpenClash_Rules'
runs-on: ubuntu-latest
timeout-minutes: 10
concurrency:
group: main-writers
outputs:
changed: ${{ steps.commit.outputs.changed }}
source_before_sha: ${{ steps.commit.outputs.source_before_sha }}
steps:
- name: Checkout main branch
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7
with:
ref: main
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97 # v7.0.0
with:
python-version: '3.13'
- name: Update and validate Encrypted_DNS.list
run: |
python -m unittest discover -s py -p 'test_rule_generation.py'
python py/update_encrypted_dns.py
python py/update_encrypted_dns.py --check
- name: Commit source-list changes
id: commit
run: |
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
# Another main writer may have finished while sources were being
# downloaded. Regenerate from the latest main instead of rebasing a
# stale list over newer repository changes.
git fetch origin main
if [ "$(git rev-parse HEAD)" != "$(git rev-parse origin/main)" ]; then
git reset --hard origin/main
python -m unittest discover -s py -p 'test_rule_generation.py'
python py/update_encrypted_dns.py
python py/update_encrypted_dns.py --check
fi
if ! git diff --quiet -- . ':(exclude)rule/Encrypted_DNS.list'; then
echo "Updater modified files outside rule/Encrypted_DNS.list" >&2
git status --short
exit 1
fi
source_before_sha="$(git rev-parse HEAD)"
git add -- rule/Encrypted_DNS.list
if git diff --cached --quiet; then
echo "changed=false" >> "$GITHUB_OUTPUT"
echo "Encrypted_DNS.list is already up to date."
exit 0
fi
git commit -m "chore(rule): auto-update Encrypted_DNS.list"
git push origin HEAD:main
echo "changed=true" >> "$GITHUB_OUTPUT"
echo "source_before_sha=$source_before_sha" >> "$GITHUB_OUTPUT"
generate-derived-rules:
needs: update-encrypted-dns
if: needs.update-encrypted-dns.outputs.changed == 'true'
permissions:
contents: write
uses: ./.github/workflows/auto-generate-rules.yml
secrets: inherit
with:
source_before_sha: ${{ needs.update-encrypted-dns.outputs.source_before_sha }}