Update gov.txt from Cloudflare zone file #217
This file contains 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: 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 "[email protected]" | |
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 |