-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #117 from cisagov/es/107-zone-file-script
107: CI to push automated gov.txt updates from CZDS API
- Loading branch information
Showing
3 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
name: Update gov.txt from CZDS API zone file | ||
run-name: Update gov.txt from CZDS API zone file | ||
|
||
on: | ||
workflow_dispatch: {} | ||
schedule: | ||
- cron: "5 6 * * *" | ||
|
||
jobs: | ||
update_zone_file: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Download gov.txt.gz | ||
env: | ||
ICANN_USERNAME: '${{ secrets.ICANN_USERNAME }}' | ||
ICANN_PASSWORD: '${{ secrets.ICANN_PASSWORD }}' | ||
run: | | ||
chmod +x ./scripts/download_zone_file.sh | ||
./scripts/download_zone_file.sh '${{ env.ICANN_USERNAME }}' '${{ env.ICANN_PASSWORD }}' > gov.txt | ||
shell: sh | ||
# Push daily zone file to branch only if a diff is found | ||
- name: Commit and push updated zone file update to branch | ||
run: |- | ||
git config user.name "botgov" | ||
git config user.email "[email protected]" | ||
git add gov.txt | ||
timestamp=$(date -u) | ||
git commit -m "CZDS Update ${timestamp}" || exit 0 | ||
git push |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
"""Authenticates into ICANN using Github Actions secrets credentials and downloads .gov zone file""" | ||
ICANN_username=$1 | ||
ICANN_password=$2 | ||
authentication_data="{\"username\":\"$ICANN_username\",\"password\":\"$ICANN_password\"}" | ||
token=$(curl -X POST -H "Accept: application/json" -H "Content-Type: application/json" -d $authentication_data https://account-api.icann.org/api/authenticate | jq -r .accessToken) | ||
[ ! -z "$token" ] && curl -X GET --output gov.txt.gz -H "Accept: application/json" -H "Content-Type: application/json" -H "Authorization: Bearer $token" https://czds-api.icann.org/czds/downloads/gov.zone && gunzip -f ./gov.txt.gz > gov.txt |