Merge pull request #41 from koenrh/support-non-default-config-path

Add support for non-default DNSControl config file location
This commit is contained in:
Koen Rouwhorst 2021-01-20 21:28:14 +01:00 committed by GitHub
commit bc4f97e60e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 41 additions and 1 deletions

View file

@ -30,6 +30,11 @@ jobs:
uses: koenrh/dnscontrol-action@v3 uses: koenrh/dnscontrol-action@v3
with: with:
args: check args: check
# Optionally, if your DNSConfig files are in a non-default location,
# you could specify the paths to the config and credentials file.
config_file: 'dns/dnsconfig.js'
creds_file: 'dns/creds.json'
``` ```
### preview ### preview
@ -56,6 +61,11 @@ jobs:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
with: with:
args: preview args: preview
# Optionally, if your DNSConfig files are in a non-default location,
# you could specify the paths to the config and credentials file.
config_file: 'dns/dnscontrol.js'
creds_file: 'dns/creds.json'
``` ```
This is the action you probably want to run for each branch so that proposed changes This is the action you probably want to run for each branch so that proposed changes
@ -130,6 +140,11 @@ jobs:
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }}
with: with:
args: push args: push
# Optionally, if your DNSConfig files are in a non-default location,
# you could specify the paths to the config and credentials file.
config_file: 'dns/dnsconfig.js'
creds_file: 'dns/creds.json'
``` ```
## Credentials ## Credentials

View file

@ -9,6 +9,14 @@ inputs:
args: args:
description: DNSControl command description: DNSControl command
required: true required: true
config_file:
description: Path to DNSControl configuration file.
required: false
default: 'dnsconfig.js'
creds_file:
description: Path to DNSControl credentials file.
required: false
default: 'creds.json'
outputs: outputs:
output: output:
description: The output of the dnscontrol command that was executed. description: The output of the dnscontrol command that was executed.

View file

@ -2,8 +2,25 @@
set -eo pipefail set -eo pipefail
# Resolve to full paths
CONFIG_ABS_PATH="$(readlink -f "${INPUT_CONFIG_FILE}")"
CREDS_ABS_PATH="$(readlink -f "${INPUT_CREDS_FILE}")"
WORKING_DIR="$(dirname "${CONFIG_ABS_PATH}")"
cd "$WORKING_DIR"
ARGS=(
"$1"
--config "$CONFIG_ABS_PATH"
)
# 'check' sub-command doesn't require credentials
if [ "$1" != "check" ]; then
ARGS+=(--creds "$CREDS_ABS_PATH")
fi
IFS= IFS=
OUTPUT="$(dnscontrol "$1")" OUTPUT="$(dnscontrol "${ARGS[@]}")"
echo "$OUTPUT" echo "$OUTPUT"