From 7e1d75042fe98d87a617cbcdc2210b4a02bdad04 Mon Sep 17 00:00:00 2001 From: Krishnan Shankar Date: Sat, 13 Apr 2024 20:52:36 -0400 Subject: [PATCH] Set up CI workflows (validate, test, deploy) These are heavily inspired by Hack Club's implementation at https://github.com/hackclub/dns --- .github/workflows/deploy.yml | 27 +++++++++++++++++++++++++++ .github/workflows/test.yml | 25 +++++++++++++++++++++++++ .github/workflows/validate.yml | 23 +++++++++++++++++++++++ scripts/deploy.sh | 3 +++ scripts/dry-run.sh | 3 +++ 5 files changed, 81 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/test.yml create mode 100644 .github/workflows/validate.yml create mode 100644 scripts/deploy.sh create mode 100644 scripts/dry-run.sh diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..68ac85d --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,27 @@ +name: deploy + +on: + workflow_dispatch: + push: + branches: + - main + +jobs: + octodns: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Deploy to production + run: ./scripts/deploy.sh + env: + CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5039c56 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,25 @@ +name: test + +on: + push: + pull_request: + +jobs: + octodns: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Install dependencies + run: pip install -r requirements.txt + + - name: Dry run + run: ./scripts/dry-run.sh + env: + CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }} diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml new file mode 100644 index 0000000..9831eba --- /dev/null +++ b/.github/workflows/validate.yml @@ -0,0 +1,23 @@ +name: validate + +on: + push: + branches: + - main + pull_request: + +permissions: + contents: read + pull-requests: write + +jobs: + json-yaml-validate: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Validate YAML + uses: GrantBirki/json-yaml-validate@v2.6.2 + with: + comment: "true" diff --git a/scripts/deploy.sh b/scripts/deploy.sh new file mode 100644 index 0000000..b4c4821 --- /dev/null +++ b/scripts/deploy.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +octodns-sync --config-file=./config/production.yaml --doit diff --git a/scripts/dry-run.sh b/scripts/dry-run.sh new file mode 100644 index 0000000..12a1c12 --- /dev/null +++ b/scripts/dry-run.sh @@ -0,0 +1,3 @@ +#!/bin/sh + +octodns-sync --config-file=./config/production.yaml