Merge pull request #18 from koenrh/koenrh/dnscontrol-v2.10

Upgrade DNSControl to version 2.10
This commit is contained in:
Koen Rouwhorst 2020-01-03 12:21:40 +01:00 committed by GitHub
commit 906f77842d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 36 additions and 10 deletions

View file

@ -1,4 +1,4 @@
FROM stackexchange/dnscontrol:v2.9@sha256:36354bc0e988cdc0fd4c9e69dee3408ca6f98014ea1c7220dff1362c1799a904
FROM stackexchange/dnscontrol@sha256:1dcbcbb72d6c1ed273b3479af9ae1ce75ccc3b0f74b91722f8a4a9f1ccacd9e6
LABEL repository="https://github.com/koenrh/dnscontrol-action"
LABEL maintainer="Koen Rouwhorst <info@koenrouwhorst.nl>"
@ -8,9 +8,7 @@ LABEL "com.github.actions.description"="Deploy your DNS configuration to multipl
LABEL "com.github.actions.icon"="cloud"
LABEL "com.github.actions.color"="yellow"
RUN apk add --no-cache \
bash~=4 \
jq~=1.6
RUN apk add --no-cache bash jq
COPY README.md /

View file

@ -27,7 +27,7 @@ jobs:
- uses: actions/checkout@master
- name: DNSControl check
uses: koenrh/dnscontrol-action@master
uses: koenrh/dnscontrol-action@v2.10
with:
args: check
```
@ -50,7 +50,7 @@ jobs:
- uses: actions/checkout@master
- name: DNSControl preview
uses: koenrh/dnscontrol-action@master
uses: koenrh/dnscontrol-action@v2.10
env:
CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }}
CLOUDFLARE_API_USER: ${{ secrets.CLOUDFLARE_API_USER }}
@ -85,7 +85,7 @@ jobs:
- uses: actions/checkout@master
- name: DNSControl push
uses: koenrh/dnscontrol-action@master
uses: koenrh/dnscontrol-action@v2.10
env:
CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }}
CLOUDFLARE_API_USER: ${{ secrets.CLOUDFLARE_API_USER }}

View file

@ -6,6 +6,9 @@ branding:
icon: cloud
color: yellow
inputs:
cloudflareApiToken:
description: Cloudflare API token
required: false
cloudflareApiUser:
description: Cloudflare API user
required: false

View file

@ -10,6 +10,7 @@ add_key () {
cat <<< "$(jq "$1 = \"$2\"" < creds.json)" > creds.json
}
CLOUDFLARE_API_TOKEN="${INPUT_CLOUDFLAREAPITOKEN:-$CLOUDFLARE_API_TOKEN}"
CLOUDFLARE_API_USER="${INPUT_CLOUDFLAREAPIUSER:-$CLOUDFLARE_API_USER}"
CLOUDFLARE_API_KEY="${INPUT_CLOUDFLAREAPIKEY:-$CLOUDFLARE_API_KEY}"
CLOUDFLARE_ACCOUNT_ID="${INPUT_CLOUDFLAREACCOUNTID:-$CLOUDFLARE_ACCOUNT_ID}"
@ -53,12 +54,25 @@ SOFTLAYER_API_KEY="${INPUT_SOFTLAYERAPIKEY:-$SOFTLAYER_API_KEY}"
VULTR_TOKEN="${INPUT_VULTRTOKEN:-$VULTR_TOKEN}"
if [[ -n "$CLOUDFLARE_API_USER" && -n "$CLOUDFLARE_API_KEY" ]]
if [[ -n "$CLOUDFLARE_API_TOKEN" ]]
then
add_key ".cloudflare.apitoken" "\$CLOUDFLARE_API_TOKEN"
# NOTE: https://stackexchange.github.io/dnscontrol/providers/cloudflare
if [[ -n "$CLOUDFLARE_ACCOUNT_ID" && -n "$CLOUDFLARE_ACCOUNT_NAME" ]]
then
add_key ".cloudflare.accountid" "\$CLOUDFLARE_ACCOUNT_ID"
add_key ".cloudflare.accountname" "\$CLOUDFLARE_ACCOUNT_NAME"
fi
# NOTE: Using the Cloudflare global API key is discouraged as that gives full
# access to your Cloudflare account.
elif [[ -n "$CLOUDFLARE_API_USER" && -n "$CLOUDFLARE_API_KEY" ]]
then
add_key ".cloudflare.apiuser" "\$CLOUDFLARE_API_USER"
add_key ".cloudflare.apikey" "\$CLOUDFLARE_API_KEY"
# NOTE: https://stackexchange.github.io/dnscontrol/providers/cloudflare
if [[ -n "$CLOUDFLARE_ACCOUNT_ID" && -n "$CLOUDFLARE_ACCOUNT_NAME" ]]
then
add_key ".cloudflare.accountid" "\$CLOUDFLARE_ACCOUNT_ID"

View file

@ -13,7 +13,7 @@ jobs:
- uses: actions/checkout@master
- name: DNSControl push
uses: koenrh/dnscontrol-action@master
uses: koenrh/dnscontrol-action@v2.10
env:
CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }}
CLOUDFLARE_API_USER: ${{ secrets.CLOUDFLARE_API_USER }}

View file

@ -22,7 +22,7 @@ jobs:
- uses: actions/checkout@master
- name: Preview
uses: koenrh/dnscontrol-action@master
uses: koenrh/dnscontrol-action@v2.10
env:
CLOUDFLARE_API_KEY: ${{ secrets.CLOUDFLARE_API_KEY }}
CLOUDFLARE_API_USER: ${{ secrets.CLOUDFLARE_API_USER }}

View file

@ -42,6 +42,17 @@ function assert_key_not_exists {
}
# Cloudflare
@test "Cloudflare API token is set in credentials file" {
export CLOUDFLARE_API_TOKEN="foo-bar-baz"
run "$WORKSPACE/entrypoint.sh"
assert_key_equals ".cloudflare.apitoken" "\$CLOUDFLARE_API_TOKEN"
assert_key_not_exists ".cloudflare.accountid"
assert_key_not_exists ".cloudflare.accountname"
}
@test "Cloudflare API user and key are set in credentials file" {
export CLOUDFLARE_API_USER="info@example.com"
export CLOUDFLARE_API_KEY="foo"