diff --git a/README.md b/README.md index 033c334..82bf163 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,11 @@ jobs: uses: koenrh/dnscontrol-action@v3 with: 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 @@ -56,6 +61,11 @@ jobs: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} with: 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 @@ -130,6 +140,11 @@ jobs: CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} with: 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 diff --git a/action.yml b/action.yml index e876cf2..8918fad 100644 --- a/action.yml +++ b/action.yml @@ -9,6 +9,14 @@ inputs: args: description: DNSControl command 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: output: description: The output of the dnscontrol command that was executed. diff --git a/entrypoint.sh b/entrypoint.sh index 0a39333..abf5ab3 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -2,8 +2,25 @@ 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= -OUTPUT="$(dnscontrol "$1")" +OUTPUT="$(dnscontrol "${ARGS[@]}")" echo "$OUTPUT"