Skip to content

Check Unmanaged Zones #20

Check Unmanaged Zones

Check Unmanaged Zones #20

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:
- uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: 3.11
- name: Install dependencies
run: |
python -m pip install -r requirements.txt
- 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: python check_unmanaged_zones.py
- 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