From 362c67c1a42caf385bc18913f3fe27954349133d Mon Sep 17 00:00:00 2001 From: Koen Rouwhorst Date: Sat, 5 Jan 2019 12:24:28 +0100 Subject: [PATCH] First commit. --- Dockerfile | 18 ++++++++++++++++++ LICENSE.txt | 15 +++++++++++++++ README.md | 35 ++++++++++++++++++++++++++++++++++- entrypoint.sh | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 118 insertions(+), 1 deletion(-) create mode 100644 Dockerfile create mode 100644 LICENSE.txt create mode 100755 entrypoint.sh diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..b960455 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,18 @@ +FROM stackexchange/dnscontrol:v0.2.8@sha256:007447bf199e74964b854b40585bd3ad1e60c6586fbb5e46c935fe9ffbaeedb3 + +LABEL repository="https://github.com/koenrh/dnscontrol-action" +LABEL maintainer="Koen Rouwhorst " + +LABEL "com.github.actions.name"="DNSControl" +LABEL "com.github.actions.description"="Deploy your DNS configuration to multiple providers." +LABEL "com.github.actions.icon"="cloud" +LABEL "com.github.actions.color"="yellow" + +RUN apk add --no-cache \ + bash~=4 \ + jq~=1.6 + +COPY README.md / + +COPY entrypoint.sh /entrypoint.sh +ENTRYPOINT ["/entrypoint.sh"] diff --git a/LICENSE.txt b/LICENSE.txt new file mode 100644 index 0000000..e625360 --- /dev/null +++ b/LICENSE.txt @@ -0,0 +1,15 @@ +ISC License + +Copyright (c) 2018, Koen Rouwhorst + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. diff --git a/README.md b/README.md index 8c8dd13..a3c1178 100644 --- a/README.md +++ b/README.md @@ -1 +1,34 @@ -# dnscontrol-action +# DNSControl Action + +Deploy your DNS configuration using [GitHub Actions](https://github.com/actions) +using [DNSControl](https://github.com/StackExchange/dnscontrol/). + +## Supported providers + +Not all [providers](https://stackexchange.github.io/dnscontrol/provider-list) are +supported yet. + +- [ ] Active Directory PowerShell +- [ ] BIND +- [x] Cloudflare +- [x] DigitalOcean +- [x] DNSimple +- [ ] Gandi +- [ ] Google Cloud DNS +- [ ] HEXONET +- [x] Linode +- [ ] Name.com +- [ ] Namecheap +- [x] NS1 +- [ ] OVH +- [x] Route 53 +- [ ] SoftLayer DNS +- [ ] Vultr + +## Usage + +TODO + +## Secrets + +TODO diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100755 index 0000000..fc3353c --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,51 @@ +#!/usr/bin/env bash + +set -euo pipefail + +# NOTE: DNSControl requires a credentials file on disk. See: https://git.io/fhIb3 +echo "{}" > creds.json + +add_key () { + # shellcheck disable=SC2094 + cat <<< "$(jq "$1 = \"$2\"" < creds.json)" > creds.json +} + +if [[ -n "$CLOUDFLARE_API_USER" && -n "$CLOUDFLARE_API_KEY" ]] +then + # NOTE: https://stackexchange.github.io/dnscontrol/providers/cloudflare + add_key ".cloudflare.apiuser" "\$CLOUDFLARE_API_USER" + add_key ".cloudflare.apikey" "\$CLOUDFLARE_API_KEY" + +elif [[ -n "$DIGITALOCEAN_OAUTH_TOKEN" ]] +then + # NOTE: https://stackexchange.github.io/dnscontrol/providers/digitalocean + add_key ".digitalocean.token" "\$DIGITALOCEAN_OAUTH_TOKEN" + +elif [[ -n "$DNSIMPLE_ACCOUNT_ACCESS_TOKEN" ]] +then + # NOTE: https://stackexchange.github.io/dnscontrol/providers/dnsimple + add_key ".dnsimple.token" "\$DNSIMPLE_ACCOUNT_ACCESS_TOKEN" + +elif [[ -n "$LINODE_ACCESS_TOKEN" ]] +then + # NOTE: https://stackexchange.github.io/dnscontrol/providers/linode + add_key ".linode.token" "\$LINODE_ACCESS_TOKEN" + +elif [[ -n "$NSONE_API_KEY" ]] +then + # NOTE: https://stackexchange.github.io/dnscontrol/providers/ns1 + add_key ".ns1.api_token" "\$NSONE_API_KEY" + +elif [[ -n "$AWS_ACCESS_KEY_ID" && -n "$AWS_SECRET_ACCESS_KEY" ]] +then + # NOTE: https://stackexchange.github.io/dnscontrol/providers/route53 + add_key ".r53.KeyId" "\$AWS_ACCESS_KEY_ID" + add_key ".r53.SecretKey" "\$AWS_SECRET_ACCESS_KEY" + + if [[ -n "$AWS_SESSION_TOKEN" ]] + then + add_key ".r53.Token" "\$AWS_SESSION_TOKEN" + fi +fi + +sh -c "dnscontrol $*"