Add scripts.
This commit is contained in:
@@ -0,0 +1,26 @@
|
|||||||
|
name: Scrape latest DNS records
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
schedule:
|
||||||
|
- cron: '0 * * * *'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
scheduled:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repo
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Fetch latest DNS records
|
||||||
|
env:
|
||||||
|
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
|
||||||
|
run: ./scrape.sh
|
||||||
|
|
||||||
|
- name: Commit and push if it changed
|
||||||
|
run: |-
|
||||||
|
git config user.name "Automated"
|
||||||
|
git config user.email "actions@git.arirex.me"
|
||||||
|
git add -A
|
||||||
|
git commit -m "Latest DNS records: $(date -u)" || exit 0
|
||||||
|
git push
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
rm -r out 2>/dev/null || true; mkdir -p out
|
||||||
|
|
||||||
|
CLOUDFLARE_API="https://api.cloudflare.com/client/v4"
|
||||||
|
HEADERS=(
|
||||||
|
-H "Authorization: Bearer ${CLOUDFLARE_API_TOKEN}"
|
||||||
|
-H "Content-Type: application/json"
|
||||||
|
)
|
||||||
|
|
||||||
|
curl -s "${CLOUDFLARE_API}/zones" "${HEADERS[@]}" | \
|
||||||
|
jq -r '.result[] | .id' | while read zone_id; do
|
||||||
|
|
||||||
|
zone_name=$(curl -s "${CLOUDFLARE_API}/zones/${zone_id}" "${HEADERS[@]}" | \
|
||||||
|
jq -r '.result.name')
|
||||||
|
|
||||||
|
echo "Fetching DNS records for: ${zone_name}"
|
||||||
|
curl -s "${CLOUDFLARE_API}/zones/${zone_id}/dns_records" "${HEADERS[@]}" | \
|
||||||
|
jq . > "out/${zone_name}.json"
|
||||||
|
done
|
||||||
Reference in New Issue
Block a user