Skip to content

Check Unmanaged Zones #148

Check Unmanaged Zones

Check Unmanaged Zones #148

name: Check Unmanaged Zones
on:
schedule:
- cron: "0 0 * * 1-5" # Runs at 00:00 from Monday to Friday
workflow_dispatch: # Allows manual triggering
jobs:
check-zones:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Set up Python 3.11
uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5.3.0
with:
python-version: 3.11
- name: Install dependencies
run: |
make install
- name: Run check for unmanaged zones
id: check-zones
env:
AWS_ACCESS_KEY_ID: ${{ secrets.OCTODNS_AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.OCTODNS_AWS_SECRET_ACCESS_KEY }}
PYTHONUNBUFFERED: 1
run: |
output=$(make check-unmanaged-zones)
echo "result<<EOF" >> $GITHUB_OUTPUT
echo "$output" >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Send notification to Slack
uses: slackapi/slack-github-action@e28cf165c92ffef168d23c5c9000cffc8a25e117 #v1.24.0
if: failure()
with:
payload: |
{
"blocks": [
{
"type": "header",
"text": {
"type": "plain_text",
"text": "⚠️ Unmanaged DNS Hosted Zones Detected ⚠️"
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "A GitHub action has detected a new hosted zone that isn't managed in the code. Details of the zone can be found below and in the GitHub Action logs. Please either delete it, update the alarm, or add the zone to octoDNS."
}
},
{
"type": "section",
"text": {
"type": "mrkdwn",
"text": "*Detected Unmanaged Zones:*\n```${{ steps.check-zones.outputs.result }}```"
}
},
{
"type": "actions",
"elements": [
{
"type": "button",
"text": {
"type": "plain_text",
"text": "View GitHub Actions Log",
"emoji": true
},
"url": "${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}"
}
]
}
]
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
SLACK_WEBHOOK_TYPE: INCOMING_WEBHOOK