Repository navigation
Fetch Cloudflare DNS Records #2763
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: Fetch Cloudflare DNS Records | |
| on: | |
| # 手动触发 | |
| workflow_dispatch: | |
| # 定时任务:每2小时运行一次 | |
| schedule: | |
| - cron: '0 */2 * * *' | |
| # 推送到main分支时触发 | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - '.github/workflows/cloudflare_dns_fetcher.py' | |
| - '.github/workflows/fetch-dns.yml' | |
| jobs: | |
| fetch-dns: | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: write | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Set up Python | |
| uses: actions/setup-python@v5 | |
| with: | |
| python-version: '3.11' | |
| - name: Install dependencies | |
| run: | | |
| pip install requests | |
| - name: Run DNS fetcher | |
| env: | |
| CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| run: | | |
| python .github/workflows/cloudflare_dns_fetcher.py | |
| - name: Commit and push results | |
| run: | | |
| git config --local user.email "github-actions[bot]@users.noreply.github.com" | |
| git config --local user.name "github-actions[bot]" | |
| git add subdomains.txt | |
| git diff --staged --quiet || git commit -m "Update DNS records - $(date +'%Y-%m-%d %H:%M:%S')" | |
| git push |