Skip to content

Update gov.txt from Cloudflare zone file #227

Update gov.txt from Cloudflare zone file

Update gov.txt from Cloudflare zone file #227

name: Update gov.txt from Cloudflare zone file
run-name: Update gov.txt from Cloudflare zone file
on:
workflow_dispatch: {}
schedule:
- cron: "5 7 * * *"
jobs:
update_zone_file:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Initialize git config and sets pull to merge
run: |-
git config user.name "botgov"
git config user.email "help@get.gov"
git config pull.rebase false
- name: Pull latest Cloudflare zone file into gov.txt
env:
CLOUDFLARE_ZONE: '${{ secrets.CLOUDFLARE_ZONE }}'
CLOUDFLARE_TOKEN: '${{ secrets.CLOUDFLARE_TOKEN }}'
run: |
chmod +x ./scripts/download_zone_file.sh
./scripts/download_zone_file.sh '${{ env.CLOUDFLARE_ZONE }}' '${{ env.CLOUDFLARE_TOKEN }}' > gov.txt
shell: sh
# Push daily zone file to branch only if a diff is found
- name: If pulled data has changes, commit and push changes to zone file.
run: |-
git add gov.txt
timestamp=$(date -u)
git commit -m "Pull Cloudflare zone data ${timestamp}" || exit 0
git pull
git push